WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. tokyobear
    Member
    Posted 9 months 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
                        ) ); ?>

    http://wordpress.org/plugins/ambrosite-nextprevious-post-link-plus/

  2. ambrosite
    Member
    Plugin Author

    Posted 9 months ago #

    Try this:

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

  3. tokyobear
    Member
    Posted 9 months 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...

    Thanks.

  4. ambrosite
    Member
    Plugin Author

    Posted 9 months 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
    Member
    Posted 9 months ago #

    I followed your advice using:

    bloginfo('template directory')

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

    get_bloginfo('template_directory')

    Thanks!

Reply

You must log in to post.

About this Plugin

About this Topic