Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Where is the key _wp_page_template passed?

The HTML attribute name is what is sent to the server. There is some PHP code reading it and storing it with a specific key in the database.

The HTML name and the database key don’t have to be the same string. The PHP code can use a completely different name or split one value into multiple database values.

The template attribute handler does that: It takes the name page_template from page attributes metabox and stores it as _wp_page_template in the database. The leading underscore protects that field from showing up in the custom fields metabox.

See this part in wp_insert_post():

if ( !empty($page_template) && 'page' == $data['post_type'] ) {
    $post->page_template = $page_template;
    $page_templates = wp_get_theme()->get_page_templates();
    if ( 'default' != $page_template && ! isset( $page_templates[ $page_template ] ) ) {
        if ( $wp_error )
            return new WP_Error('invalid_page_template', __('The page template is invalid.'));
        else
            return 0;
    }
    update_post_meta($post_ID, '_wp_page_template',  $page_template);
}

Related Posts:

  1. How to add or remove metabox each page separately?
  2. WordPress 4 and wp_editor() Not Showing Visual/Text tabs
  3. Get Order of Meta Box in a Page/Post
  4. How to add meta boxes to Pages
  5. How to create a metabox that will list all my pages in a dropdown selector?
  6. Show Custom Post Type meta boxes only on Page Edit
  7. Page template no longer exists – metaboxes won’t save
  8. Edit Parent page drop menu when creating a page
  9. Undefined index: post in NOTICE while adding meta box
  10. Set parent page based on custom metabox value
  11. Translate dashboard metabox
  12. Odd twitter meta data description on all pages
  13. Update Pages ONLY from Stage to Live (not products)
  14. Custom Upload Adds Ghost File
  15. Custom Filter using meta_value in wordpress admin list not working
  16. How to add or remove metabox each page separately?
  17. Custom SINGLE page with custom metaboxes and custom template
  18. Add infinite scroll to content splitted post
  19. Check if wp-login is current page
  20. How to get current page ID outside the loop?
  21. Contact Form on WordPress Sites?
  22. Page returns 404 with POST variables, but not without
  23. Custom templates not showing up in template dropdown
  24. Get page id by template
  25. Passing error/warning messages from a meta box to “admin_notices”
  26. Using pre_get_posts on true pages and static front pages
  27. Get the content of a specific page (by ID)
  28. Add “upload media” button in meta box field
  29. How to get page title with the page ID?
  30. Show more than 20 items in pages or posts edit dashboard
  31. Allowing user to edit only certain pages
  32. How to display last 3 posts (recent posts) in a static page?
  33. How to give paged links custom title?
  34. How to set post slug when using wp_insert_post();?
  35. How can I keep the content of my pages version controlled?
  36. How to load javascript on custom page template?
  37. How to configure WordPress to handle 75,000 pages?
  38. How to update page status from publish to draft and draft to publish
  39. Check if is on child-page of a particular page
  40. Change page template programmatically ?
  41. Conditional tag to check if ‘page.php’ is being used?
  42. Customizing the URLs of WordPress Login and Sign-up Pages?
  43. How to disable posts and use pages only
  44. What is the index [0] for on post meta fields?
  45. featured image as background image on pages
  46. Check IF is a “single product page” and Check the “role” for a Redirect
  47. A check for if is parent page, if has children, if has grandchildren
  48. How to load JS and CSS only on specific Pages using is_page()?
  49. Listing pages which uses specific template [duplicate]
  50. Proper way to get page content
  51. Access the same page from multiple urls (wildcard)
  52. Create a page without adding a page in the Database
  53. Is there a way to change the default page template selection?
  54. Can I have two child pages of different parents with the same name?
  55. What methods to use to create small, editable pieces of text for static pages?
  56. Show Default Editor on Blog Page ( Administration Panel )
  57. Hide page visual editor if certain template is selected?
  58. What is the difference between $paged and $page?
  59. post formats – how to switch meta boxes when changing format?
  60. multi page password protection
  61. Create a “Dummy” parent page for a hierarchy in page listing?
  62. How do I convert a page’s title to lower case?
  63. Get top level page parent title
  64. How to add a specific widget to only 1 page?
  65. How can I retrieve multiple get_post_meta values efficiently?
  66. Restrict admin access to certain pages for certain users
  67. page title, parent tilte and grand parent title
  68. How to add jQuery script to an individual page?
  69. WordPress page edit does not save selected template
  70. How to add add_meta_box to specific Page Template?
  71. Add a Page without header and menus?
  72. What is an alternative to get_page_by_title()?
  73. Password protect page with multiple passwords
  74. Custom field metabox not showing in back-end
  75. Create pages automatically if they don’t exist
  76. Find empty pages or pages which have less than x characters
  77. How to add a new tab to page editor
  78. Allow only new sub-pages to be created
  79. Set page template automatically based on parent
  80. Editing Complex Pages in Visual Mode
  81. Link section within page with slash (/) and not hash (#) without reloading the page
  82. Creating a template using a specific slug name, for a page with a parent page
  83. Can I display submenus in groups, using wp_list_pages?
  84. Is there a default template file for child pages / subpages?
  85. Get wp_get_attachment_url outside of loop
  86. Order by menu_order and title?
  87. Require title for pages
  88. WP Page and Subdirectory with same name
  89. Replace Dashes Before Title in Page List
  90. Upload multiple images in a custom metabox
  91. Add a new page to wordpress programmatically
  92. How to hide meta box values from custom fields list?
  93. Get Permalink for the top level parent of child pages
  94. Proper method to restrict non logged users into certain pages
  95. How to redirect on particular page in wordpress? [closed]
  96. Get page id by title?
  97. What is the use of $page_title and how to use it?
  98. How to embed page content in a blog post
  99. get registered metaboxes by post type or post ID
  100. How do I remove all the metaboxes for a custom post type?
Categories pages Tags metabox, pages, post-meta
Importing custom post types using WordPress Importer, how to check for meta field values
Where to call wp_enqueue_script in a plugin with custom template?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress