Tag Info

New answers tagged

1

As stated in my comment to the OP, you should make use of pre_get_posts to target change the query variables as needed before the main query is executed. Just a tip, pre_get_posts uses the same exact parameters as WP_Query, so you can have a look at those parameters and use them to construct your pre_get_post action parameters to modify the query variables ...


0

Thanks for your help! I've made some small adjustments and I got it working now: <?php // your taxonomy name $tax = 'cat'; // get the terms of taxonomy $terms = get_terms( $tax, $args = array( 'hide_empty' => false, // do not hide empty terms )); // loop through all terms foreach( $terms as $term ) { // Get the term link $term_link = ...


0

I didn't understood your question well, but try this. Explanation is in the comments. // your taxonomy name $tax = 'post_tag'; // get the terms of taxonomy $terms = get_terms( $tax, [ 'hide_empty' => false, // do not hide empty terms ]); // loop through all terms foreach( $terms as $term ) { // if no entries attached to the term if( 0 == ...


0

Found this code at the official Wordpress Function Reference: A simple way to get all archive-linked terms of one Taxonomy. List all the terms, with link to term archive, separated by an interpunct (ยท): $args = array( 'hide_empty=0' ); $terms = get_terms('my_term', $args); if ( !empty( $terms ) && !is_wp_error( $terms ) ) { $count = ...



Top 50 recent answers are included