Get the Category Name instead of ID from WP-API

This code will add categories_names field to wp rest api response: function wpse_287931_register_categories_names_field() { register_rest_field( ‘project’, ‘categories_names’, array( ‘get_callback’ => ‘wpse_287931_get_categories_names’, ‘update_callback’ => null, ‘schema’ => null, ) ); } add_action( ‘rest_api_init’, ‘wpse_287931_register_categories_names_field’ ); function wpse_287931_get_categories_names( $object, $field_name, $request ) { $formatted_categories = array(); $categories = get_the_category( $object[‘id’] ); foreach ($categories as $category) { $formatted_categories[] … Read more

Can I authenticate with both WooCommerce consumer key and JWT?

Yes this is possible by structuring your requests appropriately. For system requests use OAuth 1.0 (consumer key as before), but encode it to include the OAuth credentials in the URL not in the headers. Having the OAuth credentials in the Authorisation header triggers the JWT error. GET https://DOMAIN/wp-json/wc/v1/subscriptions * Authorization: `OAuth 1.0` * Consumer key: … Read more

How to use the WP REST API for new user registration (sign up form)?

hopefully you’ve found the answer already. Here’s our solution, for your reference. 😀 The following code should add User Registration via REST API to your WordPress Website. It supports Registration of ‘subscriber’ and ‘customer’. Add it to your function.php add_action(‘rest_api_init’, ‘wp_rest_user_endpoints’); /** * Register a new user * * @param WP_REST_Request $request Full details about … Read more

How to get dynamically custom post type that are under a certain category

I think you may accomplish this by using the following WP builtin features. $wp_taxonomies – global object, it stores all registered taxonomies including default and custom get_post_types() – get all registered post types including default and custom To be simple, the examples for their usage are separated below. You may then combine them to create … Read more

Reduce nonce lifespan

Yes, using that filter will affect the lifespan of all nonces created after this filter is added, and while it remains in-place. So your best bet is to add it, create the nonce, remove it: function my_nonce_lifetime() { return 600; // 10 minutes } add_filter( ‘nonce_life’, ‘my_nonce_lifetime’ ); $nonce = wp_create_nonce(‘wp_rest’); remove_filter( ‘nonce_life’, ‘my_nonce_lifetime’ );

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