How can I hide the category term for posts with none set?
You could use: <?php $categories_list = get_the_category_list( __( ‘, ‘, ‘twentyeleven’ ) ); if(has_category()) { echo $categories_list; } ?> Here’s the has_category function via the Codex.
You could use: <?php $categories_list = get_the_category_list( __( ‘, ‘, ‘twentyeleven’ ) ); if(has_category()) { echo $categories_list; } ?> Here’s the has_category function via the Codex.
Own Custom Tags/Category page ( posts)
I had a similar problem with a featured section and ended up doing it like this Fist create your array variable outside the loop: $exclude_us = array() Then add the ID of each post in the first loop into the array (in the first loop): if ( $query->have_posts() ) : while ( $query->have_posts() ) : … Read more
Adding a menu with category items / sub-items does the job here.
List Categories in Custom Order
Well after some time time and the support of the guys in ACF i got through this. My template was accessing category data only by reference, a variable was created that referenced to the category id, and by that variable the category name and other data were called. Thankfully the guys at ACF have thought … Read more
How to add an empty entry to masonry?
Conditions for single post
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
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 ) ) { … }