Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

PHP

Get terms on a archive page

1
2
3
4
5
6
7
<?php
    $queried_object = get_queried_object();
    $term_slug = $queried_object->slug;
    
    echo $term_slug;
    
?>
https://snipt.net/embed/ad8e4eb6eb6f5cd505ca91754ba95051/
https://snipt.net/raw/ad8e4eb6eb6f5cd505ca91754ba95051/
ad8e4eb6eb6f5cd505ca91754ba95051
php
PHP
7
2016-12-08T03:23:40
True
False
False
Nov 22, 2013 at 07:31 AM
/api/public/snipt/95975/
get-terms-on-a-archive-page
<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><span id="L-2"><a name="L-2"></a> <span class="nv">$queried_object</span> <span class="o">=</span> <span class="nx">get_queried_object</span><span class="p">();</span> </span><span id="L-3"><a name="L-3"></a> <span class="nv">$term_slug</span> <span class="o">=</span> <span class="nv">$queried_object</span><span class="o">-&gt;</span><span class="na">slug</span><span class="p">;</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a> <span class="k">echo</span> <span class="nv">$term_slug</span><span class="p">;</span> </span><span id="L-6"><a name="L-6"></a> </span><span id="L-7"><a name="L-7"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
archive, query, taxonomy, terms, wordpress
Copyrighted, illegal, or inappropriate content? Email [email protected].