How to run select query of post with category and tags for API?

WordPress already has an API you can extend, and a class for querying posts! For example: // when the rest_api_init action/event happens add_action( ‘rest_api_init’, function () { // register a new endpoint register_rest_route( ‘mohnish/v1’, ‘/posts/’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘mohnish_awesome_func’, // that calls this function ) ); } ); // this is whats … Read more

Create new post with meta data using WordPress API

You need to register your meta field first, then you can insert / update it into a post using rest api. https://codex.wordpress.org/Function_Reference/register_meta $object_type=”post”; $args1 = array( ‘type’ => ‘string’, ‘description’ => ‘My Meta Key Description’, ‘single’ => true, ‘show_in_rest’ => true, ); register_meta( $object_type, ‘MyMetaKey’, $args1 ); Hope it helps

CMB2 Repeatable Group & JSON API

Consider using the CMB2 API. <SITE_URL>/wp-json/cmb2/v1/boxes/<METABOX_ID>/fields/PhotoGalleryGroup?object_id=<POST_ID>&object_type=post You will need to enable the API feature for your box/fields. Documentation for that is in the wiki.

Change the CSS of the Customizer API

Definitely, you can use the customize_controls_enqueue_scripts hook to load custom CSS and JS. This is an example of making the panel 400px: File: sample-theme/css/customizer-controls.css .wp-full-overlay.expanded { margin-left: 400px; } .wp-full-overlay-sidebar { min-width: 400px; } .wp-full-overlay.collapsed .wp-full-overlay-sidebar { margin-left: -400px; } File: sample-theme/functions.php /** * Enqueue style for customized customizer. */ function sample_theme_customize_enqueue() { wp_enqueue_style( ‘custom-customize’, … Read more

POST request not going through?

I found that it didn’t work because both endpoints used the same route. I expected defining one for POST and one for GET would result in different callbacks, but they apparently conflict with each other. In a first time, I get the request going through simply by change the namespace for the POST. Maybe there … Read more

Get all PDF files from page with WordPress API

You would get the PDFs by querying mime_type=application/pdf So, based on your example your full URL would be: https://www.domain.com/wp-json/wp/v2/media?parent=1267&mime_type=application/pdf However, it is possible when using the parent=ID parameter, you will see ALL the PDFs, not just the attachments specific to that post. This happens when the PDFs were uploaded to the media library, but not … Read more

WP_REMOTE_POST Requests are being blocked by API provider [closed]

If the API is expecting a JSON object you should change your args to: $args = array ( ‘sslverify’ => false, ‘data_format’ => ‘body’, ‘headers’ => [ ‘Authorization: Bearer {API_KEY}’, ‘Content-Type: application/json’ ], ‘body’ => json_encode([ ‘region’ => ‘USA’, ‘plan’ => 1, ‘label’ => ‘API Test’, ‘app_id’ => 2 ]), ); Encode your data into … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)