get all pages list from specific template
$args = array(
'post_type' => 'page',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => '_wp_page_template',
'value' => 'page_list_R_ea_modelling_instructor_led.php' // Template file name
)
)
);
$the_pages = new WP_Query( $args );
echo "<pre>";print_r($the_pages->posts);exit;
4.29
7
global $wpdb;
$sql = "SELECT post_title, meta_value
FROM $wpdb->posts a
JOIN $wpdb->postmeta b ON a.ID = b.post_id
WHERE a.post_type = 'page'
AND a.post_status = 'publish'
AND b.meta_key = '_wp_page_template'
";
$pages = $wpdb->get_results($sql);
echo '<pre>';
print_r($pages);
echo '</pre>';
Thank you!
7
0
Are there any code examples left?
New code examples in category PHP
-
PHP 2022-03-27 22:40:03 index:of curiosa 2019 mp4
-
PHP 2022-03-27 22:35:13 Dijkstra’s algorithm php
-
PHP 2022-03-27 22:35:12 get_declared_classes
-
PHP 2022-03-27 22:30:23 php move index of a value to first position in array
-
PHP 2022-03-27 22:25:01 wordpress get_date
-
PHP 2022-03-27 21:30:38 php shorten string with dots
-
PHP 2022-03-27 21:10:46 php header 500
-
PHP 2022-03-27 21:05:06 laravel schedule run
-
PHP 2022-03-27 20:25:12 Get page title, excerpt or content by id
-
PHP 2022-03-27 20:00:27 php convert date from dd/mm/yyyy to yyyy-mm-dd