Answers for "get all pages list from specific template"

PHP
1

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;
Posted by: Guest on October-23-2020
0

check all page names with tempalte

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>';
Posted by: Guest on July-07-2020

Code answers related to "get all pages list from specific template"

Browse Popular Code Answers by Language