Skip to content

Instantly share code, notes, and snippets.

@danielpataki
Last active January 18, 2021 17:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save danielpataki/a3c6faec08535bfcb82d to your computer and use it in GitHub Desktop.
Save danielpataki/a3c6faec08535bfcb82d to your computer and use it in GitHub Desktop.
Custom Page Templates
<?php
/**
* Template Name: Alphabetical Posts
*/
get_header(); ?>
<div id="main-content" class="main-content">
<?php
if ( is_front_page() && twentyfourteen_has_featured_posts() ) {
// Include the featured content template.
get_template_part( 'featured-content' );
}
?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php
$custom_posts = new WP_Query( array(
'order_by' => 'title',
'order' => 'asc'
));
if ( $custom_posts->have_posts() ) :
while ( $custom_posts->have_posts() ) : $custom_posts->the_post();
get_template_part( 'content', get_post_format() );
endwhile;
twentyfourteen_paging_nav();
else :
get_template_part( 'content', 'none' );
endif;
?>
</div><!-- #content -->
</div><!-- #primary -->
</div><!-- #main-content -->
<?php
get_sidebar();
get_footer();
<?php
/*
Template Name: My Awesome Custom Page
*/
<?php
/*
Template Name: Stats Page
*/
?>
<h1>Hello There</h1>
$custom_posts = new WP_Query( array(
'order_by' => get_field( 'order_by' ),
'order' => get_field( 'order' )
));
<?php
/**
* Template Name: Custom Post List
*/
get_header(); ?>
<div id="main-content" class="main-content">
<?php
if ( is_front_page() && twentyfourteen_has_featured_posts() ) {
// Include the featured content template.
get_template_part( 'featured-content' );
}
?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<h1>Hello There</h1>
</div><!-- #content -->
</div><!-- #primary -->
</div><!-- #main-content -->
<?php
get_sidebar();
get_footer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment