Display posts with a particular taxonomy
-
Want to display posts with particular taxonomy such as a custom taxonomy subgroup?
Well in current Site Creator Ultimate this is about the only thing you can’t do.
But with a little code modification you can hijack the cat1 shortcode option to display any taxonomy term id. This of course includes categories, link categories, post formats, post tags , nav menu, and custom taxonomies.
The only hard part once you have done the code modification below is that you will have to get the term id to use.
For categories, link categories, tags, and custom taxonomies, just go to the relevant item in the WordPress dashboard and grab the tag_ID from the item’s link.
For these and others you can peruse the wp_terms table in the database and grab the term_id for the matching item.
To use change the following lines in the Site Creator Ultimate file lib.php for the function scu_query().
//category $c1 = scu_val('cat1', $scu_layout);
to
//category $c1 = scu_val('cat1', $scu_layout); global $wpdb; if ( $c1 ) { $taxonomy = $wpdb->get_var( $wpdb->prepare( "SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id=$c1") ); if ( $taxonomy && $taxonomy != 'category' ) { //Taxonomy is either 'link_category, post_format, post_tag, nav_menu, or custom taxonomy $q['tax_query'] = array( array( 'taxonomy' => $taxonomy, 'field' => 'id', 'terms' => $c1 ) ); $c1 = 0; } }
Cheers
TheProfessorhttps://www.ads-software.com/extend/plugins/site-creator-ultimate/
- The topic ‘Display posts with a particular taxonomy’ is closed to new replies.