I am trying to develop a custom theme for WordPress and would really like the section to be available to select your own page template for your pages in the admin area. I notice some themes have it and others do not see images below:
Without support:
With the desired support:
Is there some way to include this by modifying functions.php or another area of the themes files?
2
Answers
In WordPress, a custom page template allows you to create different layouts or designs for specific pages on your website. This customization allows you to choose a specific template for a page in the admin area, providing flexibility in how content is displayed.
that are not executed and are used for providing explanations or
notes within the code.
WordPress to define a custom page template. By adding this comment
block at the beginning of a PHP file within your WordPress theme,
you’re telling WordPress that this file can be used as a custom
template for pages. The "Template Name" is the name that will be
displayed in the WordPress admin area when selecting a template for
a page.
For instance, if you have a file named custom-template.php and it contains the code you provided, when you create or edit a page in WordPress, under the Page Attributes section, you’ll see a Template dropdown where "Template Name" will appear as an option for selecting this custom template for that specific page.
As for your goal of creating a custom theme with the ability to select page templates in the admin area, ensure the following:
WordPress theme directory.
YourTemplate at the top of each PHP file that you want to designate
as a custom template.
look for the "Page Attributes" metabox. There, you should see a
"Template" dropdown displaying the names of your custom templates.
Select the appropriate template for the page you’re editing.
Try adding support to
page-attributes
when registering your CPT.https://make.wordpress.org/support/user-manual/pages/page-attributes/