• In case you missed this, this, this, or this, I’m looking for a “previous post-home-next post” chronological navigation that begins at home (index.php). Basically, this is for a “1 posts paged” WP site.
    So far, the most promising code snippet presented has been:

    <?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>
    <?php the_date('','<h2>','</h2>'); ?>
    <?php previous_post('%', 'previous ', 'no', 'no', 1, '') ?>
    " title="home"> home
    <?php next_post('%', ' next', 'no', 'no', 1, '') ?>

    However, I want two things added:
    1. Replace the text links with images.
    2. Only have the “previous” link show on the index.php page. Currently, the “home” link is showing also, but that isn’t good because the index.php page is home.
    It was suggested that I do something with an if else combination:

    Something like :
    (in your index.php file)
    If current page is “index.php” (and nothing else after that address…)
    then echo <?php posts_nav_link('seperator','previous',''); ?>
    else echo <?php posts_nav_link('seperator','previous','next'); ?>

    I have no idea how to do this. So, I am asking for some help, please.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter pezastic

    (@pezastic)

    The solution from someone in-the-know on these forums:

    <?php
    previous_post('%','<img
    src="https://www.bbiverson.com/images/buttons/previous.jpg" alt="Read Previous Entry" align="middle" /> Previous Entry', 'no', 'no', 1, '');
    if (!((basename (__FILE__) == 'index.php') && ($_SERVER['QUERY_STRING'] ==
    ''))) {
    ?>
    &nbsp; ">Latest Entry &nbsp;
    <?php
    next_post('%','Next Entry<img
    src="https://www.bbiverson.com/images/buttons/next.jpg" alt="Read Next Entry"
    align="middle" />', 'no', 'no', 1, '');
    }
    ?>

    I’m grateful that people here are so helpful!

    Just my 2 cents… I like the method, but I’d rather have images defined in the CSS.
    So basically, I would keep the same piece of code, only defining a specific class (for example : “after” and “before”) instead of those links to images.
    The result is the same, I’m just a CSS freak. The only serious advantage I can think of, is that it makes your code more easy to read since it only contains the structure.
    You leave it to the CSS to manage the styling.

    Thread Starter pezastic

    (@pezastic)

    I don’t know anything about CSS. I really don’t have the time to learn the intracacies of it. But, I would like to know how to create a class, like you suggested. That isn’t too hard, is it? Not only am I interested in placing the images refs in CSS, but the text styling as well.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Global Post-2-Post Navigation Needed’ is closed to new replies.