[Support request] Change Location Of Post Navigation

Home Forums Support Change Location Of Post Navigation

This topic contains 10 replies, has 3 voices, and was last updated by  Tom 2 weeks, 2 days ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1208260

    Joezer

    Hello, I have disabled post navigation in customizer as I want to make it appear only in specific pages using elements so that I can also easily control which location it appears (after title). But I can’t make it appear? I’ve searched the forum for answers but I can’t find something that works. I tried:

    <?php
    if ( function_exists( ‘generate_content_nav’ ) ) {
    generate_content_nav( ‘nav-below’ );
    }
    ?>

    But it doesn’t show. It only works if I have post navigation enabled in customizer but then it would show two post navigations. One that is the default (below content) and the one that is inserted by me (using the code above). You can see it at the URL that I have provided.

    Can anyone help me to make this work?

    #1208388

    David Customer Support

    Hi there,

    may be easiest to use some CSS to hide the lower navigation. You can do this by including this style code in the same element as your navigation function:

    <style>
    .entry-meta #nav-below {
        display: none;
    }
    </style>
    #1208859

    Joezer

    Hello David,

    There is no other way to insert post navigation in other location which doesn’t rely on enabling the “display post navigation” in customizer?

    #1209067

    Tom Lead Developer

    Hi there,

    generate_content_nav() has a filter inside of it which we use to disable the post navigation if it’s disabled in the Customizer: https://github.com/tomusborne/generatepress/blob/master/inc/structure/post-meta.php#L21

    That’s why hiding the bottom navigation with CSS would work.

    Otherwise, you’ll need to build your own generate_content_nav() without the filter.

    Let me know if you need more info 🙂

    #1278521

    Joezer

    Hello,

    Apologies for the late response, just saw this today. I just have some concern regarding with SEO if I hid the post navigation via CSS. It will still be crawled by search engine spiders right? This has been my concern with this approach. As I wanted to put post navigation in between the article title and 1st paragraph and another one after the article. Both of these post navigation will be the same BUT I do not intend to do this in all of my posts, which is why I was looking for a way to only enable the the
    customized post navigation in certain pages.

    #1279413

    Tom Lead Developer

    Hi there,

    In that case, couldn’t you just disable the post navigation for the pages where you don’t want it, and hide it with CSS for pages that do have it?

    If not, creating your own pagination function is likely your best bet.

    #1279460

    Joezer

    Yes, it works. But the problem is that when I hide it with CSS, the links still appear at the source. Which means that the search engine spiders will still crawl the links.

    Are there any guides that could get me started with creating my own pagination function? Thanks

    #1279996

    Tom Lead Developer

    When you hide it with CSS, isn’t that because there is another set of pagination links on the page? If so, wouldn’t the search engines crawl those pages anyways?

    #1280438

    Joezer

    Yes, but since I have 2 post navigation already (below title, after content). If there’s a third one that’s being crawled, I think it’ll be over-optimized. I have no concrete data with this. I just know that 2 post navigation approach greatly reduces my bounce rate which is why I was doing it manually til I decided to play around with GP post nav 🙂

    #1280514

    Joezer

    I think I found a way to make the manual post navigation less tedious. I am playing around with advance custom fields and its “page links” function. It makes it easier since there is now a drop down box to choose which page you want to put in post nav. This is a lot better than manually copying the a href in each page from another tab in your browser. You can also make 2 text field for the anchor text of “page links” and another one for the title=”” tag (for SEO).

    You can prepopulate the field so if the post is divided into chapters, you can put “<< Chapter ” so the workflow will be:
    choose the page from page links box, add the anchor text, in this case I am doing a previous post link to chapter 6 so I will just put “6” in the text area since it is already prepopulated with “<< Chapter ” and then put whatever necessary text that will go to title=””. This is less confusing than manually typing a href code in html editor. And highly customizeable especially if you are trying to control your keyword density and internal links anchor ratio. You can even point it to a specific offer page since you have the ability to choose whatever link will come “next” to the post navigation. The possibilities are endless and it removes the limitation of auto generated post plus the user experience will be better but the trade off is that it will be semi-manual.

    So you will have to create one group in ACF for each. 1 group for previous post, 1 group for next post. Inside the group You will make 3 fields. Page Link, Text (for anchor text), Text (for title=””).

    Hope this helps someone that is in a unique situation as I am and who wants to take advantage of GP elements + ACF. 🙂

    #1281225

    Tom Lead Developer

    Awesome, thanks for sharing what you did with us! I’m sure someone will find it helpful 🙂

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.