• What is the best way to access poll data using custom hooks with wp rest api?

    I can access poll options, but cannot find the function to get results. Any suggestions would be helpful.

    Here is my sample code:

    if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
    
    add_action( 'rest_api_init', 'register_api_hooks' );
    function register_api_hooks() {
    
    	register_api_field(
    		'post',
    		'Yop-poll',
    		array(
    			'get_callback'    => 'get_poll_data',
    		)
    	);
    
    }
    // Return poll data
    function get_poll_data( ) {
    
    	return get_yop_poll_meta(1, 'options', true );
    
    }

    https://wordpress.org/plugins/yop-poll/

The topic ‘Access yop poll data with rest api?’ is closed to new replies.