我需要创建一个WP_Query
这只列出了一个帖子类型的特定帖子,我在查询中已经有了这一点,但我的问题是查询过滤器通过获取ID来接收,假设我有两篇帖子,其中一篇带有id=10
还有一个id=100
最后只列出id为10的帖子。
此外,如果id是通过get定义的,我需要的是,如果get发送的id包含更多的字母或数字,它会忽略,因为今天如果查询收到id 10sddds,它会接受并显示id 10的帖子,我需要查询忽略由数字和字母组成的id。
// WP_Query arguments
$args = array (
\'post_type\' => \'file\',
\'p\' => \'925s\',
\'post_status\' => \'publish\',
);
// The Query
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo get_the_title();
}
} else {
// no posts found
get_template_part( \'templates/content/not-found-search\' );
}
wp_reset_postdata();