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

Make sure you’re namespacing the class that is declaring the function, within chapters.phpnamespace absf/Chapters

Within down-latest-videos.php:

use function absf\Chapters\get_down_latest_videos; // This pulls in the function from chapters.php

$latest_four_vids = get_down_latest_videos( $post_id );

Your function get_down_latest_videos is expecting one argument to be passed – $post_id.

You’re passing it two – $curated_posts and $program_ids.

Since you’re filtering the posts within the WP_Query, you don’t need to pass in a $post_id or any arguments, unless you’re using those in the function itself to add to the filter. Currently you’re not using $post_id anywhere within the function.