wp-query and wp_get_post_terms on custom taxonomy archive page


hi so I am just wondering how I can increment the pagination of a page based upon the terms found with wp_get_post_terms() rather than the post count for the page.

this is the process i have:
custom taxonomy archive page by default presents posts ( products ) associated with that taxonomy
i alter the loop with wp query to find categories & subcategories for each post.
I then present the categories instead of the posts. I also try to remove duplicate categories.
the problem i am encountering is the pagination of the page is treating each set of terms found as one post.
i would prefer if i was somehow able to amend the pagination so that it treats the terms found as one ‘post’ rather than how it is behaving now.

can anyone help?

is my query wrong to start with? I just cannot find a way to only find related product categories for a custom taxonomy.

//$currentPage = get_query_var('paged');
 $params2 = array(
    'posts_per_page' => 1,
    'post_type' => 'product_cat',
    'field'    => 'slug',
    'order'             => 'DESC',
    'terms'     =>'product_cat',
  //  'paged'     => $currentPage,
    'tax_query' => array(
            'taxonomy' => 'workplaces',
            'field'    => 'slug',
            'terms'    => $term, 

$query2 = new WP_Query($params2);


        while ($query2->have_posts())

            $product_cats =  wp_get_post_terms(get_the_ID() , 'product_cat');
            global $post;
            //Get the current workplace slug
            foreach ($product_cats as $collection)            {
                $category_slugs[] = $collection->slug;           


    wp_reset_query() ; 
<?php $category_slugs = array_unique($category_slugs); ?>

mir 2 years 2022-03-29T06:33:43-05:00 0 Answers 0 views 0

Leave an answer