How does WordPress manage to differentiate between post and page URLs without a distinct base, and how can I replicate this functionality?

I dont know how I missed out on that while looking for aproaches, but I have a working solution now based on this answer. I modified it to check for slashes in $query->request, if there is none I first look for my custom post type (get_posts() with’slug’ => $query->request). If no post is found I … Read more

Attributes array not saving values

The best way to achieve what i was wanting to do was to use the core blocks for latest post. Then style as I needed to. Here is what my code looks like. import { registerBlockType } from “@wordpress/blocks”; import { __ } from “@wordpress/i18n”; import { useBlockProps, InnerBlocks, } from “@wordpress/block-editor”; registerBlockType(‘sfs-test-header-para-block/sfs-test-header-para-container-block’, { title: … Read more

Customizing Additional CSS editor

This is configurable using the plugin Child Theme Configurator. Here’s a screen shot. The option Separate stylesheet was selected originally. Changing it to Primary Stylesheet did the trick: Changes in Additional CSS are loaded first, and then changes in style.css in the child theme are loaded. No conflicts so far. With the Separate stylesheet setting, … 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.

Display box in sidebar of custom post type

It’s really easy, it’s called meta box and you can create one with the following code. /** * Register meta box(es). */ function plugin_prefix_register_meta_boxes() { add_meta_box( ‘meta-box-id’, __( ‘My Meta Box’, ‘textdomain’ ), ‘plugin_prefix_my_display_callback’, ‘custom_post_type’ ); } add_action( ‘add_meta_boxes’, ‘plugin_prefix_register_meta_boxes’ ); /** * Meta box display callback. * * @param WP_Post $post Current post object. … Read more

esc_html Line break

You are using single quotation in single quotation which is not possible, use one of the below approch, Approch 1 (‘ \’ ‘): ‘post_alert_user’ => esc_html__(‘Thank you for your submission at ‘, ‘usp-pro’) .$user[‘admin_name’] . esc_html__(‘! If submissions require approval, you\’ll receive an email once it\’s approved.’, ‘usp-pro’), Approch 2 (” ‘ “): ‘post_alert_user’ => … Read more