Skip to content

Instantly share code, notes, and snippets.

@wpgaurav
Last active March 24, 2023 21:16
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 wpgaurav/7496697b26f72749a075b4987f71b7a7 to your computer and use it in GitHub Desktop.
Save wpgaurav/7496697b26f72749a075b4987f71b7a7 to your computer and use it in GitHub Desktop.
Dynamic Month and Year Support in all CodeSupply Themes, sampled from SquareType. Replace template-parts/post-prev-next.php file with this code in you child or parent theme.
<?php
/**
* The template part for displaying post prev next section.
*
* @package Squaretype
*/
$prev_post = get_previous_post();
$next_post = get_next_post();
if ( $prev_post || $next_post ) {
?>
<div class="post-prev-next">
<?php
// Prev post.
if ( $prev_post ) {
?>
<a class="link-item prev-link" href="<?php echo esc_url( get_permalink( $prev_post->ID ) ); ?>">
<div class="link-content">
<div class="link-label">
<span class="link-arrow"></span><span class="link-text"> — <?php esc_html_e( 'Previous article', 'squaretype' ); ?></span>
</div>
<h2 class="entry-title">
<?php echo apply_filters( 'the_title', $prev_post->post_title ); ?>
</h2>
</div>
</a>
<?php
}
// Next post.
if ( $next_post ) {
?>
<a class="link-item next-link" href="<?php echo esc_url( get_permalink( $next_post->ID ) ); ?>">
<div class="link-content">
<div class="link-label">
<span class="link-text"><?php esc_html_e( 'Next article', 'squaretype' ); ?> — </span><span class="link-arrow"></span>
</div>
<h2 class="entry-title">
<?php echo apply_filters('the_title', $next_post->post_title ); ?>
</h2>
</div>
</a>
<?php
}
?>
</div>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment