Support » Themes and Templates » image beside edit link
9 years, 7 months ago
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.
<?php edit_post_link('<img src="image.gif" /> Edit', '', ' | '); ?>
yeah i tried that and it doesn’t work. thanks anyways.
yes it does 🙂 I tested it, AND the usage is explained inside the codex.
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.
hmm, ok then i’ll try again.
well where do you save the image, because the image still doesn’t appear.
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:
thats in keeping with how I edited the template_tag too 🙂
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.
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.
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:
so thats there is space between the image and the Edit Text.
Thanks a lot.
9 years, 6 months ago
I just wanted to say thank you to Whooami, this solved my problem as well!
youre welcome 🙂