How to make 10 post of one category

You can use pre_get_posts and is_category conditional tags to set posts_per_page to 10 for category pages. Here is a working exacmple function wpse_posts_cat_pages( $query ) { if ( $query->is_category() && $query->is_main_query() ) { $query->set( ‘posts_per_page’, ’10’ ); } } add_action( ‘pre_get_posts’, ‘wpse_posts_cat_pages’ ); What this code do: Check if it is the main query $query->is_main_query() … Read more

Highlight posts that belong to current sub category

Instead of: $categories = get_the_category(); $categories_id = $categories[0]->cat_ID; …use: $categories = wp_list_pluck( get_the_category(), ‘term_id’ ); Now you can correctly use in_array to search all the post’s categories, rather than just the first: if ( in_array( $thisTrueCat->term_id, $categories ) ) { … }

Category menu that filters out empty categories

I had an error in the above code. $key used in both for loops. Working code for filtering empty product categories out of menu items: function exclude_empty_cat_menu_items( $items, $menu, $args ) { // Get a list of product categories that excludes empty categories $non_empty_categories = get_categories(array(‘taxonomy’ => ‘product_cat’)); // Iterate over the menu items foreach … Read more

WP url to get rss with full text of post

Find an archive that displays what you want, and add /feed/ to the end e.g. /category/test becomes /category/test/feed, / becomes /feed/, /books/ becomes /books/feed If you add /feed to the end of a single posts URL you will get a comment feed You can also do /feed/rss2 or /feed/atom RSS feeds should contain a title … Read more