Wordpress-按ID加载帖子返回NULL
我使用一个带有$\u GET变量的页面模板来返回作为自定义帖子类型一部分的单个帖子的信息,但它不返回任何内容。有什么想法吗Wordpress-按ID加载帖子返回NULL,wordpress,wordpress-theming,Wordpress,Wordpress Theming,我使用一个带有$\u GET变量的页面模板来返回作为自定义帖子类型一部分的单个帖子的信息,但它不返回任何内容。有什么想法吗 <?php $args = array( 'p' => $_GET['funeralID'], // id of a page, post, or custom type 'post_type' => 'post' ); $video_
<?php
$args = array(
'p' => $_GET['funeralID'], // id of a page, post, or custom type
'post_type' => 'post'
);
$video_post = new WP_Query($args);
while ( $video_post->have_posts() ) : $video_post->the_post(); ?>
<?php the_field('archive_video_link'); ?>
我会将变量添加到WordPress的“已识别查询变量”数组中
add_action('init','add_my_vars');
function add_my_vars() {
global $wp;
$wp->add_query_var('funeralID');
}
然后可以通过
get\u query\u var('funeralID')找到'funeralID'的值代码>请参见谢谢,但这并不能解决问题。@MG1哦,问题是没有获取查询变量吗?我不太确定你想要完成什么,但可能是因为你使用的是'post\u type'=>“post”
,如果是自定义的post类型,我认为你应该使用它而不是“post”。