How to retrieve all wordpress posts (specific type) inside a function in php?


I have a function as shown below defined inside chapters.php file. The function below is retrieving all wordpress post having type absf-episodes.

function get_down_latest_videos( $post_id ) {  

 $query = new WP_Query(array(
 'post_type' => 'absf-episodes',
 'ep_integrate' => true,
 'post_status' => 'publish',
 'posts_per_page' => 4, 
 'order' => 'DESC',

 while ($query->have_posts()) {
 $post_id = get_the_ID();

 $meta_keys = array( 'title_en', 'title_short_en', 'episode_permalink-en');

 foreach ( $meta_keys as $meta_key ) {
 $my_video_data[ $meta_key ] = get_post_meta( $post_id, $meta_key, true );

 return $my_video_data;

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. Here is the complete path:

$latest_four_vods = absfEpisodesget_down_latest_videos( $curated_posts, $program_ids );

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 absf-episodes.

, user5447339 3 years 2019-11-01T10:53:59-05:00 0 Answers 72 views 0

Leave an answer