php - Exclude Wordpress Category from get_the_category_list -
I have some code that lists the category of post that you currently like ...
& lt ;? Php $ categories_list = get_the_category_list (__ (',', 'sitename')); If ($ categories_list & amp; sitename_categorized_blog ()):? & Gt; & Lt; Span class = "cat-links" & gt; & Lt ;? Php printf (__ ('All news for'% 1 $ s', 'sitename'), $ categories_list); ? & Gt; & Lt; / Span & gt; & Lt ;? Php endif; // end if categories? & Gt;
It works great, but I added a new CTG named 'Featured-Post'. How can I remove this particular post category (by name or id) from appearing in the menu created by the above code?
So instead the result ...
News for all news: Category name, Featured post
I got it ...
All news for: Category name
explanation
Hello, instead Use the wp_list_categories
function and use the 'Excluded' argument. See for more explanation.
Example
is a place where you can put this code inside your subject's functions.php
file. You have an example:
function list_categories_without_this_cat () {$ categories_stripped_of_one = wp_list_categories (array ('exit' = & gt; array (8))); Return $ categories_stripped_of_one; }
Comments
Post a Comment