WordPress Page Slug with URL custom template

Eventually I found out a solution. Below is how I have achieved this. In my functions.php file, I have put below code. add_filter(‘query_vars’, ‘add_user_var’, 0, 1); function add_user_var($vars){ $vars[] = ‘user’; return $vars; } add_rewrite_rule(‘^user/([^/]+)/?$’,’index.php?pagename=user&user=$matches[1]’,’top’); This generally adds a rewrite rule if it finds user in the URL. Now I have added a page template … Read more

I’m building a WordPress theme and noticed that the 404 page template runs along with the corresponding templates for each page. Any idea why?

I used the following function to retrieve the URLs of each page. function template_debug($filename = null) { $url = home_url($_SERVER[‘REQUEST_URI’]); debug(“Called from: $filename using URL $url \n”); } Then I inspected the front page which triggered the 404 template along with the front-page template. The Network Monitor tab showed the error, which was an incorrect … Read more

How to add readable name and description to templates?

To add a readable title to a template, we can add the following to theme.json “customTemplates”: [ { “name”: “single-post-type-name”, “title”: “Single Post Type Name” }, … But as Will mentioned in the comments, it is not possible to add descriptions yet. There is an issue to track it here: https://github.com/WordPress/gutenberg/issues/44097