Support » Fixing WordPress » posts_nav_link images

  • WordPress recommends that for links inside of posts_nav_link, you can use the example below found on this page.

    <?php posts_nav_link(' ', '<img src="images/prev.jpg" />', '<img src="images/next.jpg" />'); ?>

    So I’ve written my code like the following:

    <ul>
    <li id="previous"><?php posts_nav_link('',' ','<img src="images/prevbttn.png" />') ?>
    <li id="next"><?php posts_nav_link('','<img src="images/nextbttn.png" />',' ') ?>
    </ul>

    Do I need to use ul and li? Not necessarily, but it’s what I have at the moment, and can be easily changed later if I feel like it. Back on track, this doesn’t work. My images don’t show up – the browser recognizes an image is supposed to be there, but can’t find it.

    The big problem I’ve had with every image link I’ve propagated in PHP is that I need to use this format:

    <?php bloginfo('template_directory') ?>/images/image.extension

    But if I were to use that format in the above code in this case, the page breaks.

    <ul>
    <li id="previous"><?php posts_nav_link('',' ','<img src="<?php bloginfo('template_directory') ?>/images/prevbttn.png" />') ?>
    <li id="next"><?php posts_nav_link('','<img src="<?php bloginfo('template_directory') ?>/images/nextbttn.png" />',' ') ?>
    </ul>

    What can I do to still display the images I want to use?

Viewing 2 replies - 1 through 2 (of 2 total)
  • <ul>
    <li id="previous"><?php posts_nav_link('',' ','<img src="' . bloginfo('template_directory') .'/images/prevbttn.png" />') ?>
    <li id="next"><?php posts_nav_link('','<img src="' . bloginfo('template_directory') .'/images/nextbttn.png" />',' ') ?>
    </ul>

    I tried this, and the URL to the image path got printed out with the image still missing. Can someone please help?

    the reason this doesn’t work is cause when you use the quotes for ‘ . bloginfo(‘template_directory’) . ‘ it closes and re-opens the parameter for the posts_nav_link function.

    Solution – hardcode the address instead of using the bloginfo function so posts_nav_link(”,’ ‘,'<img src=”/wp-content/themes/yourtheme/images/prevbttn.png” />’)

    note: you can only use ” inside the parameters of posts_nav_link not just a single quote ‘

    hope this helps.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘posts_nav_link images’ is closed to new replies.