• Resolved meeramm

    (@meeramm)


    Has anyone create a REST API endpoint in YOAST SEO. I need to fetch all the data from yoast seo and return as JSON format. Any one who done this please support.
    
    add_action(‘rest_api_init’, function () {
    register_rest_route($this->namespace, ‘/get_wpsitemap’, array(
    ‘methods’ => ‘GET’,
    ‘callback’ => array($this->plugin_public, ‘yoast_seo_sitemap_cust’),
    ‘permission_callback’ => ‘__return_true’,
    ));
    });
    function yoast_seo_sitemap_cust()
    {
    global $wpdb;
    $results = $wpdb->get_results(‘SELECT * FROM xxxx_indexable‘);
    foreach ($results as $result) {
    $output[] = array(
    ‘Title’ => $result->breadcrumb_title,
    ‘permalink’ => $result->permalink,
    );
    }
    return $output;
    
    }
    
    Here i used this method to get value from Yoast. I don’t know it is correct method or not. Here i just directly fetch the value from database and add to array. Is this correct method or any other method exit. I need all the yoast data as json format. Please share the code or link.We are using a coupled architecture, so need to sent all yoast data as json formate. And now it is working. Is there any other method please share.
     
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Create REST API endpoint for indexables – Yoast SEO in WordPress’ is closed to new replies.