How do I get the information from a page template?
This is the first question of when looking to solve the problem is to display link and title of a page template that was created earlier fix that does not rely on the value of ID? . Why do they insist on not relying on page fix the value of that ID, because the ID will be assigned a value does not match the theme that you move into a new database. When the value ID will no longer true now. The code below will answer questions based on the ID of the page filled with complete page template that name, and this name will surely fixed and guaranteed it.
$pages = get_pages(array(
'meta_key' => '_wp_page_template',
'meta_value' => ''
‘hierarchical’ => 0
));
specific example: the page displays links using page template: template-profile-edit.php is public
$pages = get_pages(array(
'meta_key' => '_wp_page_template',
'meta_value' => 'template-profile-edit.php'
));
foreach($pages as $page){
echo $page->post_title.'
';
}
Details of the code:
In WordPress, each page template when creating the meta data will be saved to the key is ‘_wp_page_template’. By using get_pages function () is available in WordPress, we will ask them to take out the array’s page 2 value: meta_key, meta_value. Point of note is the need to establish ‘hierarchical’ => 0 to the search page page template is not a page from the list of that page. Then the results will show no longer true.
For more information about the content get_pages (), you can refer to the following link: get_pages () documentation available on
In WordPress, each page template when creating the meta data will be saved to the key is ‘_wp_page_template’. By using get_pages function () is available in WordPress, we will ask them to take out the array’s page 2 value: meta_key, meta_value. Point of note is the need to establish ‘hierarchical’ => 0 to the search page page template is not a page from the list of that page. Then the results will show no longer true.
For more information about the content get_pages (), you can refer to the following link: get_pages () documentation available on