• Resolved threetinytabbies

    (@threetinytabbies)


    Is there a way to add simple next / previous links above each post instead of 1 2 3 4 5 … 72 73 74 75 76 Next at the bottom of the theme layout?

    The website is threetinytabbies.com.

Viewing 12 replies - 1 through 12 (of 12 total)
  • Can you clarify what you’re trying to do? Are you trying to replace the numbered navigation (1 2 3 … Next) with a simple “Previous Page” – “Next Page” style navigation? Or are you trying to put a “Previous Post” – “Next Post” style navigation on your single post pages?

    Thread Starter threetinytabbies

    (@threetinytabbies)

    The former: I would like add next/previous links above each post and remove the numbered navigation at the bottom of the website.

    Adding single post navigation to your posts would require editing your theme’s functions.php. Normally, I recommend using a child theme so your changes won’t be lost if the theme is updated in the future, but since the theme you’re using is already a child theme, that won’t be possible. As a result, you’ll have to redo these changes if the theme is ever updated in the future.

    You can create a basic navigation with this code in your theme’s functions.php:

    function lifestyle_post_nav() {
      if ( is_single() ) {
        the_post_navigation( array(
          'prev_text' => '« %title',
          'next_text' => '%title »',
        ) );
      }
    }
    add_action( 'omega_after_content', 'lifestyle_post_nav' );

    And then you could do some basic styling with the CSS from this Pastebin: https://pastebin.com/WVWq4BDC

    Finally, you could then hide the numbered navigation with this CSS:

    .loop-pagination {
      display: none;
    }
    Thread Starter threetinytabbies

    (@threetinytabbies)

    Where do you add the code to the functions.php file? it seems that wherever I add the code, it takes the site down (syntax error) or simply adds the code above the banner image.

    The code needs to be added to the end of the file, but not the very end; it needs to be added prior to the closing PHP tag: ?>. Can you post the entirety of your theme’s functions.php to Pastebin and post the link here?

    Thread Starter threetinytabbies

    (@threetinytabbies)

    Here is the Lifestyle functions.php:

    https://pastebin.com/C8RRBan9

    I was able to add the first part of the code starting with function lifestyle_post_nav, but I don’t see that it made any difference. If I add the part from the Pastebin, it sends the site to the syntax error.

    The code from the Pastebin (and the piece of code afterwards) is CSS, not PHP, and should be put in a custom CSS plugin, not functions.php.

    Thread Starter threetinytabbies

    (@threetinytabbies)

    This worked!! Thank you so much.

    Two more questions:
    1) The next/previous links are only visible whhen you access the post by clicking on the post title. Is there any way to have those links show up when you click on the calendar, click on a category, or view the post from the home page?

    2) Can the next/previous links be moved above the comments?

    I’ll answer your questions in reverse order:

    2) Can the next/previous links be moved above the comments?

    Try this code instead:

    function lifestyle_post_nav() {
      if ( is_single() ) {
        the_post_navigation( array(
          'prev_text' => '« %title',
          'next_text' => '%title »',
        ) );
      }
    }
    add_action( 'omega_after_loop', 'lifestyle_post_nav', 5 );

    1) The next/previous links are only visible whhen you access the post by clicking on the post title. Is there any way to have those links show up when you click on the calendar, click on a category, or view the post from the home page?

    It doesn’t really make sense to have that style of navigation on pages that show multiple posts, because the context isn’t really necessary; you’re already seeing multiple posts on the page, so what would be the previous and the next post? So I’m afraid I’m still not clear on what you’re trying to do. Are you trying to replace the “1 2 3 etc”-style navigation with a “Previous Page – Next Page”-style navigation?

    Thread Starter threetinytabbies

    (@threetinytabbies)

    Try this code instead:

    function lifestyle_post_nav() {
    if ( is_single() ) {
    the_post_navigation( array(
    ‘prev_text’ => ‘« %title’,
    ‘next_text’ => ‘%title »’,
    ) );
    }
    }
    add_action( ‘omega_after_loop’, ‘lifestyle_post_nav’, 5 );

    This worked!! Thank you so much.

    Are you trying to replace the “1 2 3 etc”-style navigation with a “Previous Page – Next Page”-style navigation?

    Exactly. The next/previous links only show up if you click on the post title. If you navigate to the post, for example, by clicking on the category, there’s no way to navigate through other posts in the same category.

    Try this code in your functions.php:

    function lifestyle_page_nav() {
      the_posts_navigation( array(
        'prev_text' => '« Older Posts',
        'next_text' => 'Newer Posts »'
      ) );
    }
    add_action( 'omega_after_content', 'lifestyle_page_nav' );

    And this CSS code: https://pastebin.com/aamJ2Ayt

    Thread Starter threetinytabbies

    (@threetinytabbies)

    I adjusted it to this:

    function lifestyle_post_nav() {
    the_post_navigation( array(
    ‘prev_text’ => ‘« Older Posts’,
    ‘next_text’ => ‘Newer Posts »’
    ) );
    }
    add_action( ‘omega_after_content’, ‘lifestyle_post_nav’ );

    And it worked PERFECTLY! Thank you for all your help!!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Next / previous links’ is closed to new replies.