Skip to content

Instantly share code, notes, and snippets.

@tessak22
Created October 5, 2018 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tessak22/4d0480883e639bed703526dff7c46045 to your computer and use it in GitHub Desktop.
Save tessak22/4d0480883e639bed703526dff7c46045 to your computer and use it in GitHub Desktop.
Page template to display my Dogs Custom Post Type
<?php
/**
* Template Name: Dogs
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package WordPress
* @subpackage Twenty_Seventeen
* @since 1.0
* @version 1.0
*/
$args = array (
'post_type' => 'dogs',
);
$children = new WP_Query($args);
get_header(); ?>
<div class="wrap">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php if ($children->have_posts()) : ?>
<?php while ($children->have_posts()) : $children->the_post(); $fields = (object) get_fields(); ?>
<div>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<?php the_excerpt(); ?>
<?php if(get_field('FIELD_NAME')): ?>
<p><?php the_field('FIELD_NAME'); ?></p>
<?php endif; ?>
</div>
<?php endwhile; wp_reset_postdata(); ?>
<?php endif; ?>
</main><!-- #main -->
</div><!-- #primary -->
</div><!-- .wrap -->
<?php get_footer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment