Api rest_route 404 while building filter for custom posts (filtered by multiple meta keys / custom fields)

As I said in my comment, I made a POST request to your custom endpoint (here) and then received a 404 error with this message: “No route was found matching the URL and request method.“, which likely means the route was never registered, or that the request method was not supported, i.e. not in the … Read more

How to set a template with wp_insert_post

You can check this code I am able to work with this function cutom_function() { $new_page_id = wp_insert_post( array( ‘post_title’ => ‘PKB’, ‘post_type’ => ‘page’, ‘post_name’ => ‘pkb’, ‘comment_status’ => ‘closed’, ‘ping_status’ => ‘closed’, ‘post_content’ => ”, ‘post_status’ => ‘publish’, ‘post_author’ => get_user_by( ‘id’, 1 )->user_id, ‘menu_order’ => 0, // Assign page template ‘page_template’ => … Read more

How to set category correctly for a custom post created by a remote API call?

Functions like get_cat_ID and get_category_by_slug only work for core post categories (taxonomy category) – you are dealing with a custom taxonomy todocategories. I see you have $a2zq3_cat_name=”Category-name”; hardcoded near the top, so I assume you’re not assigning the todocategories from POST data. In which case just use wp_set_object_terms() like so. wp_set_object_terms( $a2z3_entry_post_id, [ ‘the-category-slug’ ], … Read more

Encoding Method for URLs?

On a lower level, the function sanitize_title_with_dashes() converts to lowercase, replaces spaces and non-alphanumeric characters with dashes, and urlencodes whatever you pass to it. <?php echo sanitize_title_with_dashes( ‘This is my blog post’ ); // this-is-my-blog-post

Get paged category link programmatically

This the code I have so far which looks like it does the job, I still wonder if there is a API function for the job: /** * @param (int) $category_id * @param (int) $pagenum * @return string */ function get_category_paged_link($category_id, $pagenum) { global $wp_rewrite; $link = get_category_link($category_id); if ($wp_rewrite->using_permalinks() || $wp_rewrite->using_index_permalinks()) { $link = … Read more

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