Reverse traversing taxonomy based on term_id

Thanks to @ialocin in his comment above, I took his recommendation and adapted it to fit my needs. Traversing the taxonomy hierarchy from the bottom up is actually relatively simple if you understand how WordPress does this from the top down. function origin_trail_ancestor($cat_id = 0, $link = false, $trail = false) { global $wp_query; $anchor … Read more

Custom Post type is being ignored in query

I found out that I was using pre_get_post on these pages to exclude some things on the taxonomy archive pages. add_action( ‘pre_get_posts’, ‘exclude_cpt’ ); function exclude_cpt( $query ) { if ( $query->is_tax(‘results_categories’) ) { $query->set( ‘post_type’, array(‘results’) ); } return $query; } BUT I forgot to make sure this was only happening in the main … Read more

How to output hierarchical taxonomy path, with only the deepest term assigned?

Use get_the_terms to fetch the post’s term, then use get_ancestors to get an array of that term’s parent IDs. $tax = ‘category’; $terms = get_the_terms( get_the_ID(), $tax ); if( $terms && ! is_wp_error( $terms ) ){ // check for and output any ancestors $ancestors = array_reverse(get_ancestors( $terms[0]->term_id, $tax )); if( $ancestors ){ foreach( $ancestors as … Read more

Pagination is not working on single-{slug}.php but works fine on page-{slug}.php

You forgot to start a new query. And if you dont use have post on your custom query, you will get the main current query, in your case is your single. $args = array( ‘post_type’ => ‘crew’, ‘posts_per_page’ => 10 ); $your_custom_query = new WP_Query( $args ); // is that you forgot // The Loop … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)