- This topic has 10 replies, 2 voices, and was last updated 2 years, 11 months ago by Daniel.
-
AuthorPosts
-
November 23, 2018 at 11:55 pm #737100manaadiar
Hi there.. Please see this screen shot..I am using a child theme.. While I can change style using CSS, I want to know which file I need to copy from parent theme to amend the post navigation to show NEXT or PREVIOUS instead of the actual title like it is showing now..
Also I would like the PREVIOUS to show at left edge of the block and NEXT on the right edge removing the line break/wrap within the block..
I want to make changes in the child theme as I don’t want this change to disappear when there are theme updates to parent..
November 24, 2018 at 8:32 am #737583TomLead DeveloperLead DeveloperTo change the text, add these functions:
add_filter( 'next_post_link', function( $output, $format, $link, $post ) { if ( ! $post ) { return ''; } return sprintf( '<div class="nav-next"><span class="next"><a href="%1$s" title="%2$s">Next</a></span></div>', get_permalink( $post ), $post->post_title ); }, 10, 4 ); add_filter( 'previous_post_link', function( $output, $format, $link, $post ) { if ( ! $post ) { return ''; } return sprintf( '<div class="nav-previous"><span class="prev"><a href="%1$s" title="%2$s">Previous</a></span></div>', get_permalink( $post ), $post->post_title ); }, 10, 4 );
To make them appear on either side, you can do this:
.post-navigation { display: flex; } .nav-previous { margin-right: auto; } .nav-next .next:before { display: none; } .nav-next .next:after { font-family: GeneratePress; content: "\f105"; text-decoration: inherit; position: relative; margin-left: .6em; width: 13px; text-align: center; display: inline-block; -moz-osx-font-smoothing: grayscale; -webkit-font-smoothing: antialiased; font-style: normal; font-variant: normal; text-rendering: auto; line-height: 1; speak: none; }
November 25, 2018 at 5:00 am #738297manaadiarThat worked perfectly, thanks.. Can I have a Title Tip as well which will show the title of the post..
November 25, 2018 at 5:34 pm #739104TomLead DeveloperLead DeveloperJust adjusted my instructions above: https://generatepress.com/forums/topic/changing-post-navigation-text-to-next-instead-of-title/#post-737583
November 26, 2018 at 7:48 am #739979manaadiarHi Tom, the title tip is showing but the Previous and Next has a break now like it was previously..
November 26, 2018 at 9:31 am #740122TomLead DeveloperLead DeveloperAh, sorry about that! I just adjusted the functions above 🙂
April 26, 2021 at 2:08 am #1749100DanielIs it possible to have NEXT instead of TITLE activated for a particular post category only? The rest of the categories to have the original names of posts?
April 26, 2021 at 5:46 am #1749326DavidStaffCustomer SupportHi there,
in the PHP Snippet that Tom provided you will see two instances of:
if ( ! $post ) {
Change this to:
if ( ! $post || ! in_category('your_category_slug') ) {
Change the
your_category_slug
to match the one where you want it to display Next/Previous instead of the title.April 26, 2021 at 10:54 am #1749927DanielThanks for that David. That worked for that particular category but the other categories now don’t show any post navigation at all – this area is blank?
April 27, 2021 at 1:22 am #1750415DavidStaffCustomer SupportAah this is a very old way of changing these – a lot has changed since then.
Could you raise a new topic where we can start afreshApril 27, 2021 at 2:11 am #1750469DanielWill do David thanks.
-
AuthorPosts
- You must be logged in to reply to this topic.