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

Extract image url associated to a category

I found what I needed: $category = get_category( get_query_var( ‘cat’ ) ); $cat_id = $category->cat_ID; $images = get_posts( array(‘post_type’ => ‘attachment’, ‘category__in’ => $cat_id)); if ( !empty($images) ) { foreach ( $images as $image ) { $image_url = $image->guid; } } else{ $image_url=””; } First I got the category, and current category ID I’m in. … Read more

How to Customize the category list page

WordPress determines which template file to use from its Template Hierarchy. It might be further customized by extensions and themes might be using different files for same things, depending on what they do. There are helper plugins for simpler cases (for example What The File), but it might require involved debug with more complex themes.