What to do if there is no template selection field when crea... open

What to do if there is no template selection field when creating or editing page in WordPress. Code example


function custom_page_template( $templates ) {
$templates[‘home-page.php’] = ‘Home page’;
return $templates;
}
add_filter( ‘theme_page_templates’, ‘custom_page_template’ );

This code adds a custom page template with the name “Home page” and the file “home-page.php“. The “custom_page_template” function defines a new template and adds it to the templates array. The “add_filter” function then adds this template to the WordPress theme’s list of page templates.
Steps:
1. The “custom_page_template” function creates a new page template with the name “Home page” and the file “home-page.php“.
2. The template is added to the array of templates using the “home-page.php” key.
3. The function returns the updated array of templates.
4. The “add_filter” function adds this template to the list of WordPress theme page templates.

0

More

Leave a Reply

Your email address will not be published. Required fields are marked *

How many?: 22 + 22

lil-code© | 2022 - 2024
Go Top
Authorization
*
*
Registration
*
*
*
*
Password generation