Articles of categories

Show div only if post is in specific category

In my list of blog posts, I would like to show a div which labels the post as a “Press Release” if the post is tagged with the “Press” category. I have added the following chunk into my loop: <?php if (is_category( ‘press’ )) : ?><div class=”category”>Press Release</div><?php endif;?> I have also tried replacing press […]

How do I set a specific template for sub-categories?

There’s a few posts about getting sub-categories to use the same template as their parent but I want to do something slightly different. I have a category 67, and I want all sub-categories of 67 to use a specific template. Not the default template, and not the custom category-67.php template. How do I do that? […]

How do I render all posts of the same category in same layout?

I have several posts that share the same layout but have different title and content. This layout is different from that on the site. I can use single.php to render them, but then ALL posts will have this layout. If I add some category for this posts, could I render all post in this category […]

Filter categories using tags

I have a website with the following categories: Videos Pictures Stories And I have a lot of tags like: Funny, Awesome, Mind Blowing, Crazy, etc. Is there a way I could filter lets say: Videos tagged as Crazy? I know you can do: http://domainname.com/tag/crazy/ But that would retrieve ALL content tagged as crazy, I just […]

Add inline style to get_the_category_list

I need to style the get_the_category_list() a tag but can’t seem to find a way. This is my code: echo ‘<ul class=”list-inline meta-list”>’; // Get the categories $terms = get_the_terms( get_the_ID(), ‘category’); if( !empty($terms) ) { $term = array_pop($terms); $category_color = get_field(‘category_color’, $term ); } $category_list = get_the_category_list( ‘ ‘ ); if ( $category_list ) […]

category__in not working on custom post type

Can’t get my WP_Query loop to work, cannot figure out why category__in won’t work. Just want to pull certain categories FROM my custom post type $args = array( ‘post_type’ => ‘bbt’, ‘category__in’ => array(90,89) ); $loop = new WP_Query($args); when I use echo $loop->found_posts; it does returns 0, BUT I have 2 posts in total […]

Get posts with at least one category in common with current post?

In single.php : I want to get all posts with at least one category in common with the current post. I tried reading through the wordpress codex documentation but I found it rather confusing (I’m new to php & wordpress!). I’ve already used php on wordpress but when it comes to getting posts using filters […]

How to get next previous category in same taxonomy?

Like WP get_adjacent_post function gives the next and previous post data based on the parameters i want to get the next/previous category data is there any WP built in function which does the right job or i have to write a custom query for that. // Next/previous post example $in_same_cat = false; $excluded_categories = ”; […]

Sort posts by post_type in category.php template

In my category.php template I want to sort category posts by their post types dynamic. My block must have this structure Restaurant (custom post type) – posts Bars (custom post type) – posts Shops (custom post type) – posts I need to know at first, in what post types are the posts of current category […]

Count to how many categories a post belongs to

Is there a possibility to count to how many categories a post belongs to?