Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created November 15, 2018 20:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/79180e21d715999f1577472c81d8557f to your computer and use it in GitHub Desktop.
Save billerickson/79180e21d715999f1577472c81d8557f to your computer and use it in GitHub Desktop.
<?php
/**
* Display posts about spain
*
*/
function be_display_spain_posts() {
$loop = new WP_Query( array(
'posts_per_page' => 5,
'category_name' => 'spain',
) );
if( $loop->have_posts() ):
echo '<h3>Recent posts about Spain</h3>';
echo '<ul>';
while( $loop->have_posts() ): $loop->the_post();
echo '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
endwhile;
echo '</ul>';
endif;
wp_reset_postdata();
}
add_action( 'genesis_after_entry', 'be_display_spain_posts' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment