toggle menu

Get the Page Template all pages in wordpress

Dhananjay Kumar |03 Oct at 10:10

Hi All,

I have sloved the problem with below script:

           $args = array(
                'post_type' => 'page',
                'posts_per_page' => -1,
                'meta_query' => array(
                    array(
                        'key' => '_wp_page_template',
                        'value' => 'page-template.php'
                    )
                )
            );
            $the_pages = new WP_Query( $args );
            $arraypage=array();
            $arraypagestitle=array();
            if( $the_pages->have_posts() ){
                while( $the_pages->have_posts() ){
                    $the_pages->the_post();
                    $arraypage[]=array("slug"=>get_permalink(), "title"=>get_the_title());
                }
            }
            wp_reset_postdata(); 

  • 1 like
  • 0 comment

Posted:

03 Oct at 10:10

Viewed:

972 times

Active:

03 Oct at 10:10