Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8644419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:17:20+00:00 2026-06-12T12:17:20+00:00

I have two custom post type: product and faq. The product post type has

  • 0

I have two custom post type: product and faq. The product post type has a taxonomy product_tag. So now, I want to search for text ‘food’ in both blog and faq and those products having tag as ‘food’.

This is the arguments for the query:

$args = array(
    'tax_query' => array(
        array(
            'taxonomy' => 'product_tag',
            'field' => 'slug',
            'terms' => 'food'
        )
    ),
    'post_type' => array('post', 'faq', 'product'),
    'posts_per_page' => 6,
    's' => 'food',
    'paged' => $paged
);

But I am not getting any result. If I remove the tax_query array from the code, I get the results but not all products having food as tags are displayed. It just search for the text in them.

So, what should be the modification needed so that I get relevant posts here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:17:21+00:00Added an answer on June 12, 2026 at 12:17 pm

    For anyone having interest, this is how I solved it:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    
    $args1 = array(
        'post_type' => array('post', 'faq'),
        'posts_per_page' => 6,
        's' => $problem,
        'paged' => $paged
    );
    
    $args2 = array(
        'tax_query' => array(
            array(
                'taxonomy' => 'product_tag',
                'field' => 'slug',
                'terms' => $problem
            )
        ),
        'post_type' => 'product',
        'posts_per_page' => 6,
        'paged' => $paged
    );
    
    $articleposts = get_posts( $args1 );
    $productposts = get_posts( $args2 );
    
    $mergedposts = array_merge( $articleposts, $productposts );
    
    foreach( $mergedposts as $singlepost ) : setup_postdata( $singlepost );
    ?>
    <h2><a href="<?php echo get_permalink( $singlepost->ID ); ?>"><?php echo $singlepost->post_title; ?></a></h2>
    <?php endforeach; ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom post type for my portfolio page. I have two
I have 100 property listings as wordpress posts and each post has two custom
I have a UITableView with two custom cells and each of them has a
If I am making a module, and want to have two custom paths: path/path/path/index.htm
I have setup a custom post type in Wordpress. It is a section where
I have setup a custom taxonomy called video_categories and have set it to two
I am doing some custom audio post-processing using audio units. I have two files
I have a custom post type of Products in my WordPress project. The CPT
Basically I have a custom post type setup called Parts with over 5,000 posts
I have two custom ActionFilters on an action. In first of the actionfilters, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.