WordPress.org

Ready to get started?Download WordPress

Forums

Use image as "Edit post" button (4 posts)

  1. multimolti
    Member
    Posted 5 years ago #

    Hi!

    I want to use an image instead of text for the "Edit post" link in my theme.
    When I use edit_post_link('', '', ''); it still gives me some HTML tags, thus I can't use it as image link.

    This is also not working: <?php edit_post_link('<img src="'.bloginfo('stylesheet_directory').'/icons/page_edit.png" title="Edit this page">', '', ''); ?> because the "bloginfo()" function echo's its text and doesn't return it as string.

    I also tried to do it manually, but this isn't working either, the "the_ID()" function returns nothing (""): `/wp-admin/page.php?action=edit&post=<?php the_ID(); ?>">
    <img src="<?php bloginfo('stylesheet_directory'); ?>/icons/page_edit.png" title="Edit this page">
    `

    What can I do? Please help!

  2. multimolti
    Member
    Posted 5 years ago #

    EDIT:
    These forum can't display my last solution (the manual one). Here again:

    <a href="<?php bloginfo('url'); ?>/wp-admin/page.php?action=edit&post=<?php the_ID(); ?>">
           <img src="<?php bloginfo('stylesheet_directory'); ?>/icons/page_edit.png" title="Edit this page"></a>
  3. multimolti
    Member
    Posted 5 years ago #

    Can't anybody help me? Please, I really need to get this to work!

  4. multimolti
    Member
    Posted 5 years ago #

    It's working now with this code:

    function get_ID() {
    	global $wp_query;
    	$thePostID = $wp_query->post->ID;
    	return $thePostID;
    }

    and

    <?php bloginfo('url'); ?>/wp-admin/page.php?action=edit&post=<?php echo get_ID(); ?> as link.

Topic Closed

This topic has been closed to new replies.

About this Topic