Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

PHP

WordPress: PHP 'template tag' code to display shortcode inside a page template

<?php echo do_shortcode("[shortcode]"); ?>
https://snipt.net/embed/84539a0eede12f247b52e6b1fb2f23b1/
https://snipt.net/raw/84539a0eede12f247b52e6b1fb2f23b1/
84539a0eede12f247b52e6b1fb2f23b1
php
PHP
1
2016-12-06T15:17:45
True
False
False
Dec 17, 2015 at 08:20 PM
/api/public/snipt/143152/
wordpress-php-template-tag-code-to-display-shortcode-inside-a-page-template
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nx">do_shortcode</span><span class="p">(</span><span class="s2">&quot;[shortcode]&quot;</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
shortcode, tag, template, wordpress

PHP

Add support for shortcode in text widget

1
2
3
4
/**
 * Add support for shortcode in text widget
 */
add_filter('widget_text', 'do_shortcode');
https://snipt.net/embed/77f1901ee020c36a208db0867b3e8429/
https://snipt.net/raw/77f1901ee020c36a208db0867b3e8429/
77f1901ee020c36a208db0867b3e8429
php
PHP
5
2016-12-09T20:54:32
True
False
False
Dec 13, 2013 at 01:14 PM
/api/public/snipt/100382/
add-support-for-shortcode-in-text-widget
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="x">/**</span> </span><span id="L-2"><a name="L-2"></a><span class="x"> * Add support for shortcode in text widget</span> </span><span id="L-3"><a name="L-3"></a><span class="x"> */</span> </span><span id="L-4"><a name="L-4"></a><span class="x">add_filter(&#39;widget_text&#39;, &#39;do_shortcode&#39;);</span> </span></pre></div> </td></tr></table>
"tex widget", shortcode, wordpress

Text only

Protect email from Spambots

/** Protect email address from Spambots  use with [mailto][email protected][/mailto] */
function my_mail_shortcode( $atts , $content=null ) {     for ($i = 0; $i < strlen($content); $i++) $encodedmail .= "&#" . ord($content[$i]) . ';';      return '<a href="mailto:'.$encodedmail.'">'.$encodedmail.'</a>'; } add_shortcode('mailto', 'my_mail_shortcode');
https://snipt.net/embed/a2a708a776523b7116b37da85f2b0642/
https://snipt.net/raw/a2a708a776523b7116b37da85f2b0642/
a2a708a776523b7116b37da85f2b0642
text
Text only
2
2016-12-06T11:25:28
True
False
False
/api/public/snipt/98323/
protect-email-from-spambots
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>/** Protect email address from Spambots use with [mailto][email protected][/mailto] */ </span><span id="L-2"><a name="L-2"></a>function my_mail_shortcode( $atts , $content=null ) { for ($i = 0; $i &lt; strlen($content); $i++) $encodedmail .= &quot;&amp;#&quot; . ord($content[$i]) . &#39;;&#39;; return &#39;&lt;a href=&quot;mailto:&#39;.$encodedmail.&#39;&quot;&gt;&#39;.$encodedmail.&#39;&lt;/a&gt;&#39;; } add_shortcode(&#39;mailto&#39;, &#39;my_mail_shortcode&#39;); </span></pre></div> </td></tr></table>
email, shortcode

PHP

Contenido shortcode condicional

1
2
3
4
5
6
7
<?php $shortcode_nombre = do_shortcode('[shortcode_nombre]'); ?>
<?php if( $shortcode_nombre ): ?>
	<div>
    <h2>mostrar elementos del shortcode</h2>
    <?php echo $shortcode_nombre; ?>
    </div>
<?php endif; ?>
https://snipt.net/embed/bd37c45752d1cd87ffbfe8e523242f57/
https://snipt.net/raw/bd37c45752d1cd87ffbfe8e523242f57/
bd37c45752d1cd87ffbfe8e523242f57
php
PHP
7
2016-12-06T11:26:11
True
False
False
Sep 21, 2012 at 12:35 PM
/api/public/snipt/47464/
contenido-shortcode-condicional
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> <span class="nv">$shortcode_nombre</span> <span class="o">=</span> <span class="nx">do_shortcode</span><span class="p">(</span><span class="s1">&#39;[shortcode_nombre]&#39;</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x"></span> </span><span id="L-2"><a name="L-2"></a><span class="cp">&lt;?php</span> <span class="k">if</span><span class="p">(</span> <span class="nv">$shortcode_nombre</span> <span class="p">)</span><span class="o">:</span> <span class="cp">?&gt;</span><span class="x"></span> </span><span id="L-3"><a name="L-3"></a><span class="x"> &lt;div&gt;</span> </span><span id="L-4"><a name="L-4"></a><span class="x"> &lt;h2&gt;mostrar elementos del shortcode&lt;/h2&gt;</span> </span><span id="L-5"><a name="L-5"></a><span class="x"> </span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$shortcode_nombre</span><span class="p">;</span> <span class="cp">?&gt;</span><span class="x"></span> </span><span id="L-6"><a name="L-6"></a><span class="x"> &lt;/div&gt;</span> </span><span id="L-7"><a name="L-7"></a><span class="cp">&lt;?php</span> <span class="k">endif</span><span class="p">;</span> <span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
condicional, shortcode, wordpress

Text only

integrate shortcode responsive slider as template tag

<?php do_shortcode('[responsive_slider]'); ?>
https://snipt.net/embed/33d7d065912ac1f2879f4e01a85349d0/
https://snipt.net/raw/33d7d065912ac1f2879f4e01a85349d0/
33d7d065912ac1f2879f4e01a85349d0
text
Text only
1
2016-12-10T05:53:17
True
False
False
Aug 21, 2012 at 11:56 AM
/api/public/snipt/46054/
integrate-shortcode-responsive-slider-as-template-tag
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>&lt;?php do_shortcode(&#39;[responsive_slider]&#39;); ?&gt; </span></pre></div> </td></tr></table>
"responsive slider", shortcode, wordpress
Copyrighted, illegal, or inappropriate content? Email [email protected].