最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Creating a custom WP query for a Custom Post Type

programmeradmin0浏览0评论

I'm trying to create a WP query to search a Custom post type by its title. By using the following code, I get all portfolio posts:

$search_query = array(
    'post_type' => 'portfolio',
    'posts_per_page' => 9,
    'paged' => $paged,
    'post_status' => 'publish'
);

If I add the 's' parameter to the query ($search_query['s'] = $keyword;), it ignores the 'post_type' and returns blog posts instead of portfolio posts.

发布评论

评论列表(0)

  1. 暂无评论