snipt

Ctrl+h for KB shortcuts

PHP

Add class to body if sidebar is active

1
2
3
4
5
6
7
8
<?php
function add_body_sidebar_class($classes) {
    if (is_active_sidebar('sidebar')) {
        $classes[] = 'has-sidebar';
    }
    return $classes;
}
add_filter('body_class','add_body_sidebar_class');
https://snipt.net/embed/3e8f6543c7b21b61a5ab68b31ea759d7/
https://snipt.net/raw/3e8f6543c7b21b61a5ab68b31ea759d7/
3e8f6543c7b21b61a5ab68b31ea759d7
php
PHP
8
2016-09-23T17:38:09
True
False
False
Feb 16, 2016 at 11:56 AM
/api/public/snipt/144260/
add-class-to-body-if-sidebar-is-active
<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> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a><span class="k">function</span> <span class="nf">add_body_sidebar_class</span><span class="p">(</span><span class="nv">$classes</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">if</span> <span class="p">(</span><span class="nx">is_active_sidebar</span><span class="p">(</span><span class="s1">&#39;sidebar&#39;</span><span class="p">))</span> <span class="p">{</span> </span><span id="L-4"><a name="L-4"></a> <span class="nv">$classes</span><span class="p">[]</span> <span class="o">=</span> <span class="s1">&#39;has-sidebar&#39;</span><span class="p">;</span> </span><span id="L-5"><a name="L-5"></a> <span class="p">}</span> </span><span id="L-6"><a name="L-6"></a> <span class="k">return</span> <span class="nv">$classes</span><span class="p">;</span> </span><span id="L-7"><a name="L-7"></a><span class="p">}</span> </span><span id="L-8"><a name="L-8"></a><span class="nx">add_filter</span><span class="p">(</span><span class="s1">&#39;body_class&#39;</span><span class="p">,</span><span class="s1">&#39;add_body_sidebar_class&#39;</span><span class="p">);</span> </span></pre></div> </td></tr></table>
template, wordpress

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-09-24T01:55:30
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 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

HTML

Backbone template header

1
2
3
<script type="text/template" id="">

</script>
https://snipt.net/embed/ac78ca93fe2b695448320d2db3ff62fc/
https://snipt.net/raw/ac78ca93fe2b695448320d2db3ff62fc/
ac78ca93fe2b695448320d2db3ff62fc
html
HTML
3
2016-09-21T19:03:22
True
False
False
Feb 07, 2014 at 03:58 AM
/api/public/snipt/111651/
backbone-template-header
<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></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="nt">&lt;script </span><span class="na">type=</span><span class="s">&quot;text/template&quot;</span> <span class="na">id=</span><span class="s">&quot;&quot;</span><span class="nt">&gt;</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="nt">&lt;/script&gt;</span> </span></pre></div> </td></tr></table>
backbone, template
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.