<?php | |
function ar_custom_project_endpoint($data) { | |
$args = array( | |
'posts_per_page' => -1, | |
'offset' => 0, | |
'category' => '', | |
'category_name' => '', | |
'orderby' => 'title', | |
'order' => 'ASC', | |
'include' => '', | |
'exclude' => '', | |
'meta_key' => '', | |
'meta_value' => '', | |
'post_type' => 'project', | |
'post_mime_type' => '', | |
'post_parent' => '', | |
'author' => '', | |
'post_status' => 'publish' | |
); | |
$items = get_posts( $args ); | |
$data = array(); | |
$response_data = array(); | |
foreach($items as $post) { | |
$response_data['extension_name'] = $post->post_title; | |
$response_data['extension_link'] = get_field('link',$post->ID); | |
$response_data['extension_desc'] = get_field('description',$post->ID); | |
array_push($data,$response_data); | |
} | |
return new WP_REST_Response( $data, 200 ); | |
} | |
add_action( 'rest_api_init', function () { | |
register_rest_route( 'wp/v2', '/featured-projects', array( | |
'methods' => 'GET', | |
'callback' => 'ar_custom_project_endpoint', | |
) ); | |
} ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment