admin管理员组文章数量:1122832
I am using ACF to create a custom post type (CPT = "books"). I cannot get the CPT to appear in Wordpress search results (I tried both default Elementor search widget and Jetsearch)
I have tried the following:
add_filter( 'pre_get_posts', 'custom_post_type_search' );
function custom_post_type_search( $query ) {
if ($query->is_search) {
$query->set('post_type', array( 'post', 'books'));
}
return $query;
}
Nothing seems to work. The CPT is visible, queryable, and is NOT excluded from search.
Any ideas?
Thanks in advance :)
本文标签: Fix Custom Post Type not appearing in search results
版权声明:本文标题:Fix Custom Post Type not appearing in search results? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736310967a1934568.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论