Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Template Name: List
- */
- ?>
- <style>
- td, tr{
- border: 1px solid grey;
- padding: 10px;
- }
- </style>
- <h1>
- Lista:
- </h1>
- <table>
- <tbody>
- <thead>
- <tr>
- <td>Title</td>
- <td>Link</td>
- </tr>
- </thead>
- <?php
- // WP_Query arguments
- $args = array (
- 'post_type' => 'page',
- 'posts_per_page' => 1000,
- 'meta_key' => '_wp_page_template',
- 'meta_value' => 'template_name.php'
- );
- // The Query
- $query = new WP_Query( $args );
- // The Loop
- if ( $query->have_posts() ) {
- while ( $query->have_posts() ) {
- $query->the_post();
- ?>
- <tr>
- <td><?php the_title(); ?></td>
- <td><a href="<?php the_permalink(); ?>">Link</a></td>
- </tr>
- <?php
- }
- } else {
- // no posts found
- }
- // Restore original Post Data
- wp_reset_postdata();
- ?>
- </tbody>
- </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement