WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I set an email button in functions php. The email is sent when clicking on a front-end update post button. The problem is: the email is sent but I can't get the post title to appear in the post. I guess I didn't correctly set the post_title variable... Anyway, here's the code (taken and partially edited from a old wp answers thread).

For the button

function show_publish_button2(){
Global $post;
    echo '<form name="front_end_publish" method="POST" action="">
            <input type="hidden" name="pid" id="pid" value="'.$post->ID.'">
            <input type="hidden" name="FE_PUBLISH" id="FE_PUBLISH" value="FE_PUBLISH">
            <input type="submit" name="submit" id="submitp2" value="" onClick="return confirm(\'are you sure?\')">

for updating the post and emailing

if (isset($_POST['FE_PUBLISH']) && $_POST['FE_PUBLISH'] == 'FE_PUBLISH'){
if (isset($_POST['pid']) && !empty($_POST['pid'])){
update_post_meta((int)$_POST['pid'], 'rivedi_check', 'false');
$ogg = $post->post_title;
    $to = 'email@adress.com';
$subject = 'Post updated';
$message = 'Post title '.$ogg;

I also tried with:

$ogg = get_post($post->ID, post_title);

But it's the same, it doesn't work. The only thing that is written in the email body I receive is: "Title of the post: ".

share|improve this question
up vote 1 down vote accepted

it looks like you should use

$mypost = get_post($_POST['pid']);
$ogg = $mypost->post_title;

instead of

$ogg = get_post($post->ID, post_title);
share|improve this answer
Yes, it works! Thanks :) – She Hulk Feb 14 '13 at 19:39
ok great, good luck with your project ;-) – birgire Feb 14 '13 at 19:48
i definitely need it :P – She Hulk Feb 14 '13 at 19:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.