Answers for "wordpress rest api tags"

0

wordpress rest api tags

add_action('rest_api_init', 'bs_rest_api_hooks');
function bs_rest_api_hooks() {
    register_rest_field(
        'post',
        'mtags',
        array(
            'get_callback' => 'm_get_tags',
        )
    );
}
function m_get_tags($object, $field_name, $request) {

    $tags = get_the_tags($object["id"]);

    return $tags;
}
Posted by: Guest on July-14-2021

Browse Popular Code Answers by Language