0

Hi i have created a custom search with the following query. But the query is not working when i add multiple values to the post_type filed, the search is not giving me any results? did you have the same problem and how did you managed to resolve it? Im using woocommerce. this query only works with one value on the post_type i don't know what is wrong here ?

wp-query

$args = array(
            's' => $searchterm,
            'post_type' => array( 'product','post', 'page'),
            'posts_per_page' => $max_posts_per_page,
            'orderby'   => 'date',
            'paged' => $paged
        );
        
        $the_query = new WP_Query($args);
1
  • register same taxonomy for multiple post types. use same name/slug/etc. "my_one_taxonomy" and then register it for all post types. Commented Dec 3, 2020 at 12:33

1 Answer 1

0

Hi i found my my problem it was polylang that causes the problem i need to add sopport for products to polylang settings so my fast fix was just to add 'lang'=> '' because my site is only in English at this moment.

<?php $args = array(
            's' => $searchterm,
            'post_type' => array( 'product','post', 'page'),
            'posts_per_page' => $max_posts_per_page,
            'orderby'   => 'date',
            'paged' => $paged,
            'lang'=> ''
        );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.