我有一个如下定义的函数chapters.php 文件在下面的函数中,我试图检索所有具有类型的wordpress帖子sdft-episodes.
=> chapters.php:
namespace SDFT\\Chapters;
function get_down_latest_videos( $post_id ) {
$query = new WP_Query(array(
\'post_type\' => \'sdft-episodes\',
\'post_status\' => \'publish\',
));
while ($query->have_posts()) {
$query->the_post();
$post_id = get_the_ID();
}
}
我想在其他文件中调用此函数。我要调用上述函数的文件名是down-latest-videos.php. => down-latest-videos.php:
下面是完整的路径和内部代码down-latest-videos.php:
$latest_four_vods = \\SDFT\\Chapters\\get_down_latest_videos( $post_id );
print_r($latest_four_vods); // Line A
上述代码在文件中down-latest-videos.php. 上面的A行没有打印任何内容。Problem Statement :
我想知道我应该在上面的函数中做些什么更改,这样当它在任何地方被调用时,都应该显示所有具有类型的wordpress帖子sdft-episodes
. A行应打印应打印具有类型的所有wordpress帖子sdft-episodes
.