snipt

Ctrl+h for KB shortcuts

Text only

Exclure des catégories de la boucle WordPress

1
2
3
4
5
6
7
8
// Exclude category from home
function myFilter($query) {
    if ($query->is_home) {
        $query->set('category__not_in',array(39,10));
    }
return $query;
}
add_filter('pre_get_posts','myFilter');
https://snipt.net/embed/0de371cb05aea4c74ba19d33276ee386/
/raw/0de371cb05aea4c74ba19d33276ee386/
0de371cb05aea4c74ba19d33276ee386
text
Text only
8
2019-08-17T09:39:23
True
False
False
/api/public/snipt/50391/
exclure-des-categories-de-la-boucle-word-press
<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></span><span id="L-1"><a name="L-1"></a>// Exclude category from home </span><span id="L-2"><a name="L-2"></a>function myFilter($query) { </span><span id="L-3"><a name="L-3"></a> if ($query-&gt;is_home) { </span><span id="L-4"><a name="L-4"></a> $query-&gt;set(&#39;category__not_in&#39;,array(39,10)); </span><span id="L-5"><a name="L-5"></a> } </span><span id="L-6"><a name="L-6"></a>return $query; </span><span id="L-7"><a name="L-7"></a>} </span><span id="L-8"><a name="L-8"></a>add_filter(&#39;pre_get_posts&#39;,&#39;myFilter&#39;); </span></pre></div> </td></tr></table>
php, wordpress

Text only

Utiliser les shortcodes dans les widgets

1
2
3
if ( !is_admin() ) {
    add_filter('widget_text', 'do_shortcode', 11);
}
https://snipt.net/embed/5c047ed47135dd6e32e3f627be073e49/
/raw/5c047ed47135dd6e32e3f627be073e49/
5c047ed47135dd6e32e3f627be073e49
text
Text only
3
2019-08-17T09:39:32
True
False
False
Nov 13, 2012 at 04:29 PM
/api/public/snipt/49218/
utiliser-les-shortcodes-dans-les-widgets
<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></span><span id="L-1"><a name="L-1"></a>if ( !is_admin() ) { </span><span id="L-2"><a name="L-2"></a> add_filter(&#39;widget_text&#39;, &#39;do_shortcode&#39;, 11); </span><span id="L-3"><a name="L-3"></a>} </span></pre></div> </td></tr></table>
php, wordpress