Please note that we provide the code snippets and content on this page are without any guarantee or support. In most cases, these pages are created on requests or based on individual solutions sent to us by other users. After it was published, we are only reviewing the code and content when we are made aware of an issue. Please let us know if you find one.

Please only use the codes if you understand them and know how to add custom code to your WordPress site.

By default, Advanced Ads doesn’t enable the REST API for ads.

Use the following code to change the post type definition and enable the REST API endpoint.

/** * Enable REST API support for the ad post type */ add_filter( 'advanced-ads-post-type-params', function( $post_type_params ) { $post_type_params[ 'show_in_rest' ] = true; return $post_type_params; } );
Code language: PHP (php)

Now, you can find the REST endpoint returning the ads under /wp-json/wp/v2/advanced_ads.

Please see Adding REST API Support for Custom Post Types for further adjustment options.