Page Title as Subject in Contact Form - by Royalty

This topic has 3 replies, 2 voices, and was last updated 7 years, 3 months ago ago by Rose Tyler

  • Avatar: Royalty
    Royalty
    Participant
    July 28, 2017 at 19:00

    Hello,
    I would like to show the current page title as subject in the Royal contact form. I found that I will have to edit theme-functions.php but I dont know what to edit. I’ve tried to replace:
    'You have been contacted by ' . $name;
    with:
    $subject = $post_title;
    But I have to define $post_title somewhere and I just dont know where and how.
    I would really appreciate your help.
    Many thanks in advance!

    2 Answers
    Avatar: Royalty
    Royalty
    Participant
    July 28, 2017 at 19:01

    I can not edit my post (still the same problem in this forum, it says “You cannot create new topics.”), so I have to correct my post here: The code I’ve replaced is:
    $subject = 'You have been contacted by ' . $name;
    with
    $subject = $post_title;

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    July 31, 2017 at 10:46

    Hello,

    Please use this code

    global $post;
    esc_html( get_the_title( $post->'ID' ) );
    
    global $post;
    
    $subject = esc_html( get_the_title( $post->'ID' ) );

    Regards

  • Viewing 3 results - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.Log in/Sign up

8theme customization service
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.