On a Genesis customization project I worked on today, the requirement was to place links to Previous and Next posts at the top of single Posts and to limit their link text to a set number of characters so they do not appear on two lines.
Before:
After:
Here's one way in which this can be set up in Genesis:
We shall duplicate genesis_prev_next_post_nav()
inside genesis/lib/structure/post.php and in this new function replace the calls to previous_post_link()
with previous_post_link_plus()
and next_post_link()
with next_post_link_plus()
whilst passing our desired number of characters for the max length of links' text.
Then inside a function hooked to loop_start
action we are going to call the above function if the plugin is active, otherwise the standard genesis_prev_next_post_nav()
.
loop_start
is the one that's above genesis_before_entry
, the location where the post navigation is to be displayed. Refer to the visual hook guide.
Step 1
Install and activate Ambrosite Next/Previous Post Link Plus plugin.
Step 2
Add the following in child theme's functions.php:
To view the full content, please sign up for the membership.
Already a member? Log in below or here.