Get ID and slug from taxonomy object

It sounds like you’re looking for the get_term_link() function. Your code will look something like this: <?php $catid = get_sub_field(‘selected_category’); $term_link = get_term_link( intval( $catid ), ‘product_cat’ ); ?> <h4><a href=”https://wordpress.stackexchange.com/questions/95584/<?php echo esc_url( $term_link ); ?>”><?php the_sub_field(‘title’); ?></a></h4> As you can see, get_term_link() takes two argument, the term and taxonomy. If you’re saving the term … Read more

How can I display all post IDs from the taxonomy?

Just some code to get started. This will get you all the IDs for job_listings that are assigned to term 4 in your taxonomy. <?php $posts = get_posts( array( ‘posts_per_page’ => -1, ‘fields’ => ‘ids’, ‘post_type’ => ‘job_listing’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘agency’, ‘field’ => ‘term_id’, ‘terms’ => 4 ) ) ) ); … Read more

Paginated Taxonomy Term Archive including one post per term

As discussed in chat and as @Rarst already told you, there’s no default WordPress way to accomplish Archive of multiple taxonomies and all their terms In fact there’s no way to accomplish Archive of single taxonomy and all its terms in WordPress. Simply because WordPress doesn’t do that – without custom SQL queries. But there’re … Read more

Taxonomy , subtaxonomy,child taxonomy of a product woocommerce

Based on this answer, here is my function to get all your terms in an array : function get_term_ancestors($post_id, $taxonomy){ // Declare the array where we are going to store the terms $ancestors = array(); // start from the current term $parent = array_shift(get_the_terms($post_id,$taxonomy)); // climb up the hierarchy until we reach a term with … Read more

WP_Query tax_query on ACF post_object

Update 1 As @Florian pointed out, we do not need to use the wp_list_pluck function, we could simply add the ‘fields’ => ‘ids’ to the WP_Query to retrieve the list of ids: $producers = new WP_Query( array( ‘fields’ => ‘ids’, ‘post_type’ => ‘producers’, ‘posts_per_page’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => ‘region’, ‘field’ => … Read more

get complex results set according to category structure

Thinking aloud here… $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => array( ‘relation’ => ‘OR’, array( ‘taxonomy’ => ‘category’, ‘field’ => ‘term_id’, ‘terms’ => array( 202, 203 ), ‘include_children’ => 1, ), array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘category’, ‘field’ => ‘term_id’, ‘terms’ => array( 100 ), ‘include_children’ => false, ) ), ), ); … Read more

Custom taxonomy template not working with simple loop. Multiple CPT using the same taxonomy

WP defaults to showing normal native Posts in archives. It won’t automagically pick up which post types you want in your archive. You will have to adjust main query for it to explain that to it, with something like: add_action( ‘pre_get_posts’, function ( WP_Query $query ) { if ( $query->is_main_query() && $query->is_tax( ‘department’ ) ) … Read more

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