• Resolved mrblab24

    (@mrblab24)


    Hi there, I have created an custom setting page pod. Now, how can I get the data with WP REST API?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support pdclark

    (@pdclark)

    There is not currently a REST API endpoint created for settings pages in Pods. To access settings via the REST API, create a custom endpoint.

    For example, to register a route which would output some_setting from a Settings Pod named example_settings at the URL /wp-json/example/v1/settings:

    <?php
    
    add_action( 'rest_api_init', function() {
    	register_rest_route(
    		'example/v1',
    		'settings',
    		[
    			'methods'  => 'GET',
    			'callback' => function( WP_REST_Request $request ){
    				$settings_pod = pods( 'example_settings' );
    
    				return [
    					'some_setting' => $settings_pod->field( 'some_setting' ),
    				];
    			},
    		]
    	);
    } );
    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @mrblab24

    We havent heard from you anymore so I’m closing this topic.
    Feel free to reopen if you still need help!

    Cheers, Jory

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Custom Settings Pod Data With RESR API’ is closed to new replies.