Skip to content

Instantly share code, notes, and snippets.

@ChrisCree
Last active June 9, 2021 15:09
Show Gist options
  • Save ChrisCree/4c0f82411b8f1f53e646 to your computer and use it in GitHub Desktop.
Save ChrisCree/4c0f82411b8f1f53e646 to your computer and use it in GitHub Desktop.
Add Previous/Next navigation links to individual AgentPress Listings in the Genesis theme framework.
<?php
// Do not copy opening PHP tag above
// Add this code to your theme's functions.php file
// Add Previous/Next navigation to single listings
add_action( 'genesis_loop', 'wsm_add_listings_navigation' );
function wsm_add_listings_navigation() {
// bail if we aren't on a single listing CPT
if ( ! is_singular( 'listing' ) ) {
return;
}
// Add the links
echo '<div class="listing-nav previous">';
previous_post_link( '%link', 'Previous Listing' );
echo '</div>';
echo '<div class="listing-nav next">';
next_post_link( '%link', 'Next Listing' );
echo '</div>';
}
.listing-nav {
width: 50%;
}
.listing-nav.previous {
float: left;
text-align: left;
}
.listing-nav.next {
float: right;
text-align: right;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment