Add block templates (html) via plugin for custom post type
Add block templates (html) via plugin for custom post type
Add block templates (html) via plugin for custom post type
Custom PHP Template in Twenty Twenty-Four
How to create a template for a post in Query Loop block?
How to prevent random 302 canonical-ish redirect on custom template
How to change layout of post types templates dynamically for separate posts?
Display A Post At A URL without Redirecting
Normally, my-custom-page/ would be rewritten to index.php?page_id=2 (or whatever the ID of that particular page is). Your rewrite is omitting the page_id var, which is why you’re getting the blog index instead of your page.
Try this. Here is the full code that you can add to your functions.php file: // Add custom rewrite rules function add_custom_rewrite_rules() { add_rewrite_rule( ‘^category/([0-9]+)/?$’, ‘index.php?term_id=$matches[1]’, ‘top’ ); flush_rewrite_rules(false); // Temporarily set this to true to flush rules, then set back to false } add_action(‘init’, ‘add_custom_rewrite_rules’); // Add term_id to query vars function add_query_vars($vars) { … Read more
How can I allow plugin users to define layouts for a custom post type
You are already using the correct action, i.e. wp.data.dispatch( ‘core/editor’ ).editPost(), however, you should instead change the property named template. I.e. wp.data.dispatch( ‘core/editor’ ).editPost( { template: ‘article.php’ } ) Yes, _wp_page_template is the meta key in the database, but in the REST API, a property named template exists in place of direct access on that … Read more