Ambrosite Next/Previous Post Link Plus
[resolved] Using PHP in array for image link (5 posts)

  1. tokyobear
    Posted 2 years ago #

    Firstly -- thank you for the plugin. It's absolutely great!

    I have one question about using PHP in my array for the image link. I think I have to use get_bloginfo() to get the correct directly since...

    <img src="images/right-arrow.png" />

    ... doesn't show the image. But I can't use php inside the text if I start 'img src=...

    Currently my array is as per below, but for the 'link' it is just outputting [site name]/images/right-arrow.png as text... What should I do? Thanks in advance!!

    <?php next_post_link_plus( array(
                        'order_by' => 'post_date',
                        'loop' => true,
                        'format' => '%link',
    		    'link' => get_bloginfo('template directory').'/images/right-arrow.png',
                        'in_same_cat' => true,
                        'in_same_tax' => true
                        ) ); ?>


  2. ambrosite
    Plugin Author

    Posted 2 years ago #

    Try this:

    'link' => '<img src="' . get_bloginfo('template directory'). '/images/right-arrow.png" />',

  3. tokyobear
    Posted 2 years ago #

    Thank you for the prompt response!

    I'm afraid that didn't work. Incidentally, I'm testing on a localhost if that makes any difference?? I know the following works in CSS:

    background-image: url(../mulberry/images/background-3.png);

    And I tried adding the 'mulberry' (theme name) into your code:

    '<img src="' . get_bloginfo('template directory'). 'mulberry/images/right-arrow.png" />',

    But to no avail. I'm sure the issue is my end so I'll keep on trying...


  4. ambrosite
    Plugin Author

    Posted 2 years ago #

    Have you tried viewing the HTML source on that page to see what is actually being output by the function? I think you are probably very close, it is just a matter of getting the URL right.

  5. tokyobear
    Posted 2 years ago #

    I followed your advice using:

    bloginfo('template directory')

    to echo the function and I realised that I just needed the underscore! =)



Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Ambrosite Next/Previous Post Link Plus
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic