Get Custom URL For Custom Taxonomy

Sorry to come to the party late. Here is my solution <?php //Retrieve the terms in productcategory taxonomy with posts (not empty) $terms = get_terms( array ( ‘taxonomy’ => ‘productcategory’, ‘hide_empty’ => false, ‘parent’ => 0, ‘orderby’ => ‘description’, ‘order’ => ‘ASC’ )); //loop through each term to get its attributes foreach ($terms as $term) … Read more

Query with custom taxonomy not working

The solution is to use: ‘taxonomy’ => ‘meal’, ‘field’ => ‘slug’, ‘terms’ => ‘breakfast’ The taxonomy and terms are obvious, but why does field have to be slug? When you add taxonomy parameters, you can specify what ‘breakfast’ is– via the field. It could be the term’s ID, the full name, or slug. See the … Read more

Add/Remove current_page_parent class

Replace news with your custom post type and menu-item-000 with the menu item you want to highlight. function wpdev_nav_classes($classes) { // Remove “current_page_parent” class $classes = array_diff( $classes, array( ‘current_page_parent’ ) ); // If this is the “news” custom post type, highlight the correct menu item if ( in_array(‘menu-item-000’, $classes) && get_post_type() === ‘news’ ) … Read more

Displaying custom taxonomy terms active trail

Maybe better to use wp_list_catergories.. codex: wp list categories $args = array( ‘taxonomy’ => ‘type’, ‘orderby’ => ‘name’, ‘show_count’ => false, ‘pad_counts’ => false, ‘hierarchical’ => true, ‘title_li’ => ” ); <ul> <?php wp_list_categories( $args ); ?> </ul> and add to css: .current-cat{ background-color: #d86f08; }

How to Get Current Custom Post Type Selected Taxonomy Term (Not All Terms)

There are several ways to achieve this. Using get_the_terms: $args = array( ‘post_type’ => ‘movies’, ‘posts_per_page’ => 10 ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); ?> <?php the_title(); $terms = get_the_terms( get_the_ID(), ‘genre’ ); if ( is_array( $terms ) ) { //Manipulate array of WP_Term objects } ?> <div … Read more

Display Posts in Custom Post Types Timber

It’s a late reply and I suspect you might have it figured out already, but if someone is looking for the same info, here’s an example. {% for post in posts %} {% set post_terms = post.terms(‘tour_category’) %} {% if function( ‘has_term’, ‘Sightseeing Tours’, ‘tour_category’ ) %} {% set teaser=”sightseeing” %} {% elseif function( ‘has_term’, … Read more

Category taxonomy template not working for custom post

The hierarchy for a custom taxonomy is listed below: taxonomy-{taxonomy}-{term}.php: For example, if the taxonomy is named “sometax,” and the taxonomy’s term is “someterm,” WordPress would look for a file named taxonomy-sometax-someterm.php. taxonomy-{taxonomy}.php: For example, if the taxonomy is named “sometax,” WordPress would look for a file named taxonomy-sometax.php taxonomy.php archive.php index.php url: /you_site.com/portfolio_category/term_name Provided … Read more