Skip to content

Instantly share code, notes, and snippets.

@NatalieMac
Created February 22, 2020 18:44
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 NatalieMac/7492960b55f6df1bc09060936ede2cbd to your computer and use it in GitHub Desktop.
Save NatalieMac/7492960b55f6df1bc09060936ede2cbd to your computer and use it in GitHub Desktop.
<?php
$args = array(
'post_type' => 'patient-education',
'posts_per_page' => 4,
'post_parent' => $post->ID,
'orderby' => 'title',
'order' => 'ASC',
);
$related = new WP_Query( $args );
if ( $related->have_posts() ) : ?>
<h2>Related articles</h2>
<?php while ( $related->have_posts() ) : $related->the_post(); ?>
<div id="parent-<?php the_ID(); ?>" class="parent-page">
<h1><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1>
<p><?php the_excerpt(); ?></p>
</div>
<?php endwhile; ?>
<?php endif; wp_reset_postdata(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment