• Hi !
    I have ninja table plugin and in wp rest api controller I wanna make a link for call just a parameter like ” _ninja_table_column ” not all of them .
    I was wondering if you tell which link can I use for it .
    that link
    &_fields[]=_ninja_table_columns
    is not working !

Viewing 1 replies (of 1 total)
  • Plugin Contributor jpowersdev

    (@jpowersdev)

    Hi @aminaghamiri,

    When you hit the main route that our plugin customizes (i.e. /wp/v2/ninja-table), our plugin registers callback on the fly to make those fields available. However, when you modify the route (i.e. by adding query params to filter out fields) it becomes necessary to register those fields separately.

    In this case, you’d probably want to add something like this to your theme’s functions.php file:

    add_action('rest_api_init', function(){
    	register_rest_field('ninja-table', '_ninja_table_columns', array(
    		'get_callback' => function($params){
    			return \get_post_meta($params['id'], '_ninja_table_columns', true);		
    		}
    	));
    });

    Doing that makes the field globally available to rest API routes and you should then be able to make a request for just that field.

    Let me know if that helps,
    Jon

Viewing 1 replies (of 1 total)
  • The topic ‘how can I call some parameter ?’ is closed to new replies.