Change the slug of post type using custom code

There is a function called wp_unique_post_slug which is called whenever you save a post. This function contains a filter of the same name that you can use to modify the slug, depending on, for instance, the post type. This example will prepend the slug with the post type, so you can see from the slug … Read more

Get featured image thumbnail and inserting into custom field on wordpress posts

You will want to make the following changes to your add_custom_field_automatically function. First, we will need to add the global $post; as we will need the $post variable inside the function scope. You do this with a comma. more on variable scope here. add_action(‘publish_post’, ‘add_custom_field_automatically’); function add_custom_field_automatically($post_ID) { global $wpdb, $post; if(!wp_is_post_revision($post_ID)) { add_post_meta($post_ID, ‘field-name’, … Read more

REST API – Retrieving posts with custom status

Yes, authentication is needed, because the Posts endpoint will check whether the current user has the edit_posts capability – see WP_REST_Posts_Controller::sanitize_post_statuses(). Also, a HTTP status of 401 normally indicates that authentication is required. So try again, but with an authenticated request, i.e. make sure the current user is logged-in and has the edit_posts capability.

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