Custom REST endpoint not working to retrieve single posts (“rest_no_route”)

I’ve got the following basic route for my custom REST endpoint: add_action(‘rest_api_init’, ‘my_cpt_route’); function my_cpt_route() { register_rest_route(‘mytheme/v1/’, ‘my_cpt’, array( ‘methods’ => WP_REST_SERVER::READABLE, ‘callback’ => ‘my_cpt_results’, )); } And this is the CB function: function my_cpt_results() { $args = array( ‘post_type’ => array(‘my_cpt’), ‘posts_per_page’ => -1, ); $mainQuery = new WP_Query($args); $results = array(); while ($mainQuery->have_posts()) […]

CMS Mastering Development Wordpress

Get get Current Page ID in functions php, meta query filter

How do I get the Current Page ID in functions php when creating an meta query filter? I’ve made many attempts but all return Null. The filter works as expected when I manually input a number, but I need it to automatically echo the current post ID. Any guidance is appreciated, thanks. $args = array( […]

CMS Development Wordpress

Filter posts by their related field’s custom field

I have two post types named ‘programs’ and ‘universities’, where the programs are connected to their respective universities. I want to filter programs by university’s custom fields such as ranking or location. I can filter and display the programs by their own custom fields using WP_Query. However, I cannot filter them by their related post’s […]