Exclude Posts From Specific Category from Next and Previous post links

Use the 4th parameter $excluded_terms http://codex.wordpress.org/Function_Reference/next_post_link <?php next_post_link( $format, $next, $in_same_term = true, $excluded_terms=”402″, $taxonomy = ‘category’ ); ?> Same for the previous_post_link http://codex.wordpress.org/Template_Tags/previous_post_link $previous=”<span class=”meta-nav”>Previous Post</span>”; $next=”<span class=”meta-nav”>Next Post</span>”; <?php previous_post_link( $format, $previous, $in_same_term = true, $excluded_terms=”402″, $taxonomy = ‘category’ ); ?> Or you could create a template tag like whats included in Twenty … Read more

If posts category is “cars”, display image

You can make use of the conditional tag has_catgeory. You can do something like this if(has_category( ‘cars’ ) || has_category( ‘uncategorized’ )) { //display cars image }elseif(has_category( ‘banana’ )) { //display banana image } From your comments, here is your code <?php if(has_category( ‘Update’ ) || has_category( ‘uncategorized’ )) { ?> <img alt=”Hello!” src=”https://wordpress.stackexchange.com/questions/161368/<?php bloginfo(“template_directory’); … Read more

how to show the post category name

There is: the_category(), which not only seems to be all to fittingly named. Aside from that, don’t use query_posts, as for the why take a look at those two threads: When to use WP_query(), query_posts() and pre_get_posts When should you use WP_Query vs query_posts() vs get_posts()?

Enter a variable in the ‘category_name’ parameter

Yes you can pass the variable in category_name. But I think it should be get_the_title() instead of the_title(). $title = get_the_title(); $args = array( ‘category_name’ => $title ); Try this. But remember category_name only accepts category slug, not category name. You can also use following method if your page title/slug are different. And I think … Read more

Show number of articles in menu

I think it would be useful to create a custom walker for your menu. In the following code example I made use of the Menu Item Object. You can take a look at the object output here. An object type is specified for every menu item. So I just compare if the object is a … Read more

Assign automatically and manually modify category

Well, what is the expected behavior? You use wp_set_object_terms and pass just a single term. If you want to make sure the specified term is assigned to the post, while being able to add as many other terms as you like, try it like this: function add_bookcategory_automatically( $post_id ) { if ( ! wp_is_post_revision( $post_id … Read more