Community Forums › Forums › Archived Forums › General Discussion › Showcase theme – prev and next post link filter not working??
- This topic has 1 reply, 2 voices, and was last updated 7 years, 12 months ago by Victor Font.
-
AuthorPosts
-
December 16, 2016 at 7:09 am #197679mmjaegerMember
I'm using the following code to show previous and next post links on the single post page - the links actually show up after the content showing the title of the previous and next post - however, the filters don't seem to work - I'm not able to change the link text.
what am I missing?
Thanks
//* Add post navigation (requires HTML5 theme support) add_action( 'genesis_entry_footer', 'genesis_prev_next_post_nav' ); //* Customize the next page link in the entry navigation add_filter ( 'genesis_next_link_text' , 'showcase_next_page_link' ); function showcase_next_page_link( $text ) { //var_dump($text); return 'Next Page »'; } //* Customize the previous page link in the entry navigation add_filter ( 'genesis_prev_link_text' , 'showcase_previous_page_link' ); function showcase_previous_page_link( $text ) { //var_dump($text); return '« Previous Page'; }
December 16, 2016 at 1:50 pm #197699Victor FontModeratorI can confirm that the code isn't working in the current version of Genesis. If we walk through your code to see what Genesis is doing, we can see that add_action( 'genesis_entry_footer', 'genesis_prev_next_post_nav' ); is simply a helper function that adds theme support for genesis-adjacent-entry-nav.
With this theme support turned on, the genesis_adjacent_entry_nav() function executes. This function does not use any Genesis filters. It echos the WordPress previous_post_link and next_post_link functions. There are no filters for this functions. The formatting is passed as a parameter when the functions are called. So since you can't use the Genesis filters, you have to create your own functions. I've tested the following code in my local environment with the Genesis Sample Theme, but it should still work with the Showcase.
add_action( 'genesis_entry_footer', 'genesis_prev_next_post_nav' ); remove_action( 'genesis_after_entry', 'genesis_adjacent_entry_nav' ); add_action( 'genesis_entry_footer', 'my_custom_prev_next_post_nav' ); /** * my_custom_prev_next_post_nav * * @since 1.0.0 * * @return void */ function my_custom_prev_next_post_nav () { if ( ! is_singular() || ! post_type_supports( get_post_type(), 'genesis-adjacent-entry-nav' ) ) { return; } genesis_markup( array( 'open' => '<div %s>', 'context' => 'adjacent-entry-pagination', ) ); echo '<div class="pagination-previous alignleft">'; previous_post_link( '%link', '« Previous Page' ); echo '</div>'; echo '<div class="pagination-next alignright">'; next_post_link( '%link', 'Next Page »' ); echo '</div>'; genesis_markup( array( 'close' => '</div>', 'context' => 'adjacent-entry-pagination', ) ); }
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet? -
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.