Last active
November 26, 2018 01:39
-
-
Save gregrickaby/6115852 to your computer and use it in GitHub Desktop.
Display all posts in a page template
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: All Posts | |
* | |
* This template lists all posts via WP_Query and get_posts(); | |
*/ | |
get_header(); | |
// WP_Query arguments | |
$args = array ( | |
'posts_per_page' => '-1', | |
'ignore_sticky_posts' => true, | |
'order' => 'DESC', | |
'orderby' => 'date', | |
'cache_results' => true | |
); | |
// Hook into WP_Query and pass default arguments | |
getposts = get_posts( $args ); | |
// Loop through each post | |
foreach( $getposts as $post ) : ?> | |
<h1><?php the_title(); ?></h1> | |
<?php the_excerpt(); ?> | |
<?php endforeach; | |
get_sidebar(); | |
get_footer(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment