admin管理员组文章数量:1313143
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 ?
$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);
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 ?
$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);
Share
Improve this question
edited Dec 3, 2020 at 22:34
fuxia♦
107k38 gold badges255 silver badges459 bronze badges
asked Dec 3, 2020 at 12:07
Wilmar AriasWilmar Arias
1111 bronze badge
1
- register same taxonomy for multiple post types. use same name/slug/etc. "my_one_taxonomy" and then register it for all post types. – Zaheer Abbas Commented Dec 3, 2020 at 12:33
1 Answer
Reset to default 0Hi 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'=> ''
);
本文标签: I have problems with the search query using multiple post types
版权声明:本文标题:I have problems with the search query using multiple post types 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741943002a2406250.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论