WordPress.org

Forums

image beside edit link (14 posts)

  1. mmmariap
    Member
    Posted 7 years ago #

    Hey,

    I was just wondering if there was any way to put an image beside the edit link in the posts. But to have it so it only appears when the edit link does.

    Thanks.

  2. whooami
    Member
    Posted 7 years ago #

    <?php edit_post_link('<img src="image.gif" /> Edit', '', ' | '); ?>

  3. mmmariap
    Member
    Posted 7 years ago #

    yeah i tried that and it doesn't work. thanks anyways.

  4. whooami
    Member
    Posted 7 years ago #

    yes it does :) I tested it, AND the usage is explained inside the codex.

  5. whooami
    Member
    Posted 7 years ago #

    http://codex.wordpress.org/Template_Tags/edit_post_link

    here's a screenshot of the output with the source XHTML below it, I used exactly what I told you to use.
    The black square is image.gif.

    http://www.village-idiot.org/broke/imright.gif

  6. mmmariap
    Member
    Posted 7 years ago #

    hmm, ok then i'll try again.

  7. mmmariap
    Member
    Posted 7 years ago #

    well where do you save the image, because the image still doesn't appear.

  8. whooami
    Member
    Posted 7 years ago #

    it doesnt matter where you save the image if you use the full uri to the image inside the code.

    Consider this, for example:

    your site is at http://www.domain.com

    you want to use an image that is inside /thingys/

    the correct way to do that would be:

    <?php edit_post_link('<img src="http://www.domain.com/thingys/image.gif" /> Edit', '', ' | '); ?>

    To answer your question though, for purposes of my example, my image was, and still is, right here:

    http://bigbox.village-idiot.org/image.gif

    thats in keeping with how I edited the template_tag too :)

  9. mmmariap
    Member
    Posted 7 years ago #

    Oh ok. See I was using the <?php bloginfo('stylesheet_directory'); ?> for the src. But is there no way to use that, i mean say you want to change the location of the theme or w/e.

  10. whooami
    Member
    Posted 7 years ago #

    well is the image going to change if you change themes? I spose it could..

    this works for me:

    <?php edit_post_link(' <img src="'. get_bloginfo('stylesheet_directory') .'/test.gif" /> Edit', '', ' | '); ?>

    where test.gif is inside my current theme directory.

  11. whooami
    Member
    Posted 7 years ago #

    you could do this too if you dont want the image be part of the actual link.

    <?php edit_post_link('Edit', '<img src="'. get_bloginfo('stylesheet_directory') .'/test.gif" /> ', ' | '); ?>

    there is an intentional extra space in the above example after:

    '/test.gif" />

    and before:

    ',
    so thats there is space between the image and the Edit Text.

  12. mmmariap
    Member
    Posted 7 years ago #

    Thanks a lot.

  13. artfulalibi
    Member
    Posted 7 years ago #

    I just wanted to say thank you to Whooami, this solved my problem as well!

  14. whooami
    Member
    Posted 7 years ago #

    youre welcome :)

Topic Closed

This topic has been closed to new replies.

About this Topic