Skip to content

Instantly share code, notes, and snippets.

@dannydickson
Last active April 29, 2021 23:09
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 dannydickson/861cd2001e4a3d814ed6a0258414906a to your computer and use it in GitHub Desktop.
Save dannydickson/861cd2001e4a3d814ed6a0258414906a to your computer and use it in GitHub Desktop.
CCPR - Parks and Greenways Single Post Loop for Sidebar
<?php
/*
* The WordPress Query class.
*
* @link http://codex.wordpress.org/Function_Reference/WP_Query
*/
$args = array(
'p' => get_field('blog_post'),
'posts_per_page' => 1,
);
$query = new WP_Query($args);
if ($query->have_posts()) : ?>
<?php while ($query->have_posts()) : $query->the_post(); ?>
<?php get_template_part('template-parts/content', 'post') ?>
<?php endwhile; ?>
<?php
wp_reset_query();
else :
return;
endif;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment