Support » Plugins » Hacks » List Posts/Pages Based On PHP Template?

  • Is there a way to print a hierarchy of posts/pages/custom post types based on page template?

    EG. I am often asked to review another web site and I’d like a way to ‘see’ all the pages that are assigned to the ‘Newsletter’ PHP template and all the pages assigned to the ‘Product Info’ PHP template.

    In fact, if someone could tell me where the page template info is stored in the db I guess I could just loop through WP_Posts, right?



Viewing 1 replies (of 1 total)
  • J M


    It seems to me that you want to create another page template called Archives or something similar. There are plenty of guides available on Google on how to do that. In that page template, you will want to create 2 loops: one that calls Product Info CPT and one that pulls Newsletter CPT posts. Inside each loop, you want to include a call to the permalink of each post. Does that sound like a reasonable solution?

    More info on calling CPTs here.

    Essentially, you’d want something like this:

    $args = array( 'post_type' => 'your-CPT-taxonomy-here', 'posts_per_page' => 10 );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post();
    	echo '<div class="entry-content">';
    	echo '</div>';

    ^^If you want a simple “list”, then remove the_content(), and replace with the_permalink().

Viewing 1 replies (of 1 total)
  • The topic ‘List Posts/Pages Based On PHP Template?’ is closed to new replies.