Last active
March 24, 2023 21:16
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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