WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Help with "Next" and "Previous" code (9 posts)

  1. BigScaryRobot
    Member
    Posted 3 years ago #

    Hey,

    I'm trying to change the "next and "preivous" text links into images, but I can't seem to get the code right. Can anyone lend a hand? Here's the code from my index.php file:

    <div id="nextprevious">
    <div class="alignleft"><?php posts_nav_link('','','&laquo; PREVIOUS ENTRIES') ?></div>
    <div class="alignright"><?php posts_nav_link('','NEXT ENTRIES &raquo;','') ?></div>
    <div class="cleared"></div>
    </div>

    Thanks.

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    have you tried to follow the example in http://codex.wordpress.org/Function_Reference/posts_nav_link

  3. BigScaryRobot
    Member
    Posted 3 years ago #

    Yes, using that code makes the navigation disappear entirely. I think I have that Kubrick problem and I'm not sure how to fix it within this theme (Pixeled).

  4. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    Yes, using that code makes the navigation disappear entirely.

    can you still see some of the next/prev code in the html in the browser?
    link to your site?

    what happens if you try to use next_posts_link() and previous_posts_link() with the image code instead?

  5. BigScaryRobot
    Member
    Posted 3 years ago #

    I'm probably not coding it right, but I was able to get one button to appear using this code:

    <div id="nextprevious">
    <?php posts_nav_link( ' ', '<img src="' . get_bloginfo('stylesheet_directory') . '/images/prev.png" />', '<img src="' . get_bloginfo('stylesheet_directory') . '/images/next.png" />' ); ?>
    </div> <!-- Closes contentwrapper-->

    However, it only seems to be the NEXT button. The PREVIOUS button just disppears.

    My site is http://flowersarepretty.com

  6. BigScaryRobot
    Member
    Posted 3 years ago #

    Here's the original Index.php for reference:

    [moderated: chunk of code removed as per forum rules - please use a pastebin for larger amounts of code]

  7. BigScaryRobot
    Member
    Posted 3 years ago #

    Okay, I think it's sort of working now. But notice on this page (http://flowersarepretty.com/?paged=2) how NEXT and PREVIOUS are right next to each other. Any way to fix that so they are on either side of the post like before?

  8. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    your latest code seems to have lost the divs with the .alignleft and .alignright css classes.

    you might be able to add something like:
    style="float:left;" and/or style="float:right;" to your code;

    post the few lines of the nav if not sure (using the code button or backticks); for larger code please use the http://wordpress.pastebin.com/

  9. BigScaryRobot
    Member
    Posted 3 years ago #

    That worked! Here's the final code. Not sure if I did it right, but it works. :)

    <div id="nextprevious">
    <?php posts_nav_link( ' ', '<img src="' . get_bloginfo('stylesheet_directory') . '/images/next.png" style="float:right;"/>', '<img src="' . get_bloginfo('stylesheet_directory') . '/images/prev.png" style="float:left;" />' ); ?>
    </div> <!-- Closes contentwrapper-->

    Thanks so much for your help!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.