Last active
November 30, 2015 20:00
-
-
Save rabidgadfly/728bd6c61d66f1263a73 to your computer and use it in GitHub Desktop.
This page template will provide a listing of all posts under the specified post type, in this case 'project'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Template Name: Project Listing | |
| * | |
| * Selectable from a dropdown menu on the edit page screen. | |
| */ | |
| ?> | |
| <?php get_header(); ?> | |
| <div id="container"> | |
| <div id="content"> | |
| <?php | |
| $type = 'project'; | |
| $args=array( | |
| 'post_type' => $type, | |
| 'post_status' => 'publish', | |
| 'posts_per_page' => -1, | |
| 'caller_get_posts'=> 1 | |
| //,'category' => '', | |
| //,'category_name'=>'sports' //optionally filter by category | |
| //,'tag'=>'football' //optionally filter by tag | |
| //,'offset' => 0 | |
| //,'orderby' => 'date' | |
| //,'order' => 'DESC' | |
| //,'include' => '' | |
| //,'exclude' => '' | |
| //,'meta_key' => '' | |
| //,'meta_value' => '' | |
| //,'post_mime_type' => '' | |
| //,'post_parent' => '' | |
| //,'author' => '' | |
| //,'suppress_filters' => true | |
| ); | |
| $my_query = new WP_Query($args); | |
| if( $my_query->have_posts() ) { | |
| while ($my_query->have_posts()) : $my_query->the_post(); ?> | |
| <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p> | |
| <?php | |
| endwhile; | |
| } | |
| wp_reset_query(); // Restore global post data stomped by the_post(). | |
| ?> | |
| </div><!-- #content --> | |
| </div><!-- #container --> | |
| <?php get_sidebar(); ?> | |
| <?php get_footer(); ?> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use, create a page template, paste this code into it and save it. Then, create a Page and assign the page template you just created. Visiting the page will display a listing of all $type Posts.