WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Add post title to edit entry link (4 posts)

  1. Packer Greg
    Member
    Posted 2 years ago #

    I would like to add the title of a post to the "edit entry" link at the bottom of the post (i.e. Edit post for Chocolate Chip Cookie Recipe ยป )

    Among other things, I have tried

    <?php edit_post_link('Edit post for <?php the_title(); ?>', '<p>', '</p>'); ?>

    but the title never displays. I've also tried get_the_title and single_post_title to no avail.

  2. Hristo SiteGround
    Member
    Posted 2 years ago #

    The following code will do fine for you:

    <?php
    $titlename =  get_the_title();
    $title = 'Edit post for '. $titlename;
    edit_post_link($title, '<p>', '</p>');
    ?>
  3. Packer Greg
    Member
    Posted 2 years ago #

    Thank you. PHP is starting to make sense to me. I hope to pay it forward some day.

  4. Hristo SiteGround
    Member
    Posted 2 years ago #

    I'm glad that it worked for you :)

Topic Closed

This topic has been closed to new replies.

About this Topic