Last active
September 16, 2021 14:26
-
-
Save marklchaves/48786abd125ce30f5140dd2e344f8411 to your computer and use it in GitHub Desktop.
Avada - Override Previous and Next for Portfolio Single and Archive
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
/** | |
* This JavaScript will override the Previous and Next pagination labels for the Avada Portfolio | |
* archive page. | |
* | |
* Target HTML | |
* | |
* <a class="pagination-prev" rel="prev" href="http://avada.local/portfolio-items/"><span class="page-prev"></span><span class="page-text">COOL</span></a> | |
* | |
* <a class="pagination-next" rel="next" href="http://avada.local/portfolio-items/page/2/"><span class="page-text">RIGHT ON</span><span class="page-next"></span></a> | |
* | |
*/ | |
(function () { | |
const prevElt = document.querySelector( | |
".post-type-archive-avada_portfolio .pagination-prev .page-text" | |
); | |
if (prevElt) prevElt.textContent = "The Beatles"; // OVERRIDE PREVIOUS | |
const nextElt = document.querySelector( | |
".post-type-archive-avada_portfolio .pagination-next .page-text" | |
); | |
if (nextElt) nextElt.textContent = "The Roling Stones"; // OVERRIDE NEXT | |
})(); |
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 | |
/** | |
* Override Previous and Next in for the single portfolio posts. | |
* | |
* You should be able to do this with JavaScript too using the archive JS | |
* function above as an example. | |
*/ | |
?> | |
<!-- Line 52 Override Previous --> | |
<a href="<?php echo esc_url_raw( $previous_post_link ); ?>" rel="prev"><?php esc_html_e( 'Go that way', 'fusion-core' ); ?></a> | |
<!-- Line 83 Override Next --> | |
<a href="<?php echo esc_url_raw( $next_post_link ); ?>" rel="next"><?php esc_html_e( 'Go this way', 'fusion-core' ); ?></a> | |
<?php | |
/** | |
* An even better experience is to replace the static text with the title of the previous and next portfolio item. | |
* See an example of how to do that here https://gist.github.com/marklchaves/52e184d4749724dad042a95966a37d4a | |
*/ | |
?> |
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 | |
/** | |
* Override Avada/includes/lib/inc/functions.php fusion_pagination() | |
* | |
* The fusion_pagination() function is pluggable, so you'll need to check if it exists | |
* first. For example: | |
* | |
* if ( ! function_exists( 'fusion_pagination' ) ) {} | |
* | |
*/ | |
// Line 1151 | |
$output .= '<span class="page-text">' . esc_html__( 'COOL', 'Avada' ) . '</span>'; // OVERRIDE THE PREVIOUS LABEL | |
// Line 1197 | |
$output .= '<span class="page-text">' . esc_html__( 'RIGHT ON', 'Avada' ) . '</span>'; // OVERRIDE THE NEXT LABEL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment