• Resolved dustindriver

    (@dustindriver)


    Hi,

    My theme uses this code for the previous/next links at the bottom of every post:

        $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
        $next     = get_adjacent_post( false, '', false );

    I want it to link to the previous/next posts in the category.

    How would I modify the above code?

Viewing 5 replies - 1 through 5 (of 5 total)
  • What theme are you using? If it is a custom theme we are happy to help here. However, if it is a third-party theme you will need to contact your theme developers.

    Moderator bcworkz

    (@bcworkz)

    Just change the false in get_adjacent_post() to true.

    Thread Starter dustindriver

    (@dustindriver)

    I did that and it breaks the theme.

    Have you tried this:

    $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post_link( true, '', true );
        $next     = get_adjacent_post( false, '', false );

    Also, if you are not using a custom theme make sure you are making changes like this in a child theme https://developer.www.ads-software.com/themes/advanced-topics/child-themes/

    Hope this helps. Once you find a solution please tag the thread as resolved.

    Thread Starter dustindriver

    (@dustindriver)

    Hey guys, thanks for the help!

    I figured it out. The theme function above is only being used for the image background of the previous/next nav. I changed the values to “true” there, which pulled the images from the previous/next posts in the category like I wanted.

    Then I had to make a change on the single.php page, which was using get_the_post_navigation. I just had to add the proper $args there and it’s fine.

    And yep, modifying a child theme.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Previous/next post in category’ is closed to new replies.