I have a function as shown below defined inside chapters.php file. In the function below, I am trying to retrieve all wordpress post having type 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();
}
}
I want to call this function in a different file. The file name where I want to call the above function is down-latest-videos.php.
=> down-latest-videos.php:
Here is the complete path and code inside down-latest-videos.php:
$latest_four_vods = \SDFT\Chapters\get_down_latest_videos( $post_id );
print_r($latest_four_vods); // Line A
The above code is inside the file down-latest-videos.php. Line A above doesn't print anything.
Problem Statement :
I am wondering what changes I should make in the function above so that when it is called anywhere it should show all the wordpress post having type sdft-episodes
.
Line A should print should print all wordpress post having type sdft-episodes
.