Wordpress: place php title into an input text area???

Discussion in 'HTML & Website Design' started by locals, Jun 22, 2013.

  1. #1
    Okay last wordpress question for a while... I promise

    I would like to have the title show up inside the input box for my contact form. but since it is inside of the text area it displays the "?php the_title(); ?" instead of the actual title name. how can I make it understand that it should be reading the php code instead of displaying it as text?

      <textarea name="cuf_msg'.$n.'" id="cuf_msg'.$n.'" class="cuf_textarea" cols="50" rows="10">'.$cuf_msg.'I am interested in <?php the_title(); ?></textarea>
    Code (markup):
     
    locals, Jun 22, 2013 IP
  2. joshuthomas

    joshuthomas Well-Known Member

    Messages:
    595
    Likes Received:
    9
    Best Answers:
    1
    Trophy Points:
    140
    #2
    its easy.
    search for the plugin exec php (link below). This plugin allows you to enable your blog to read and execute php text on pages. hope thats what you are looking for..
    http://wordpress.org/plugins/exec-php/
     
    joshuthomas, Jun 22, 2013 IP
  3. locals

    locals Well-Known Member

    Messages:
    1,677
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    153
    #3
    okay so that plugin is a little over two years old and has not had any updates, needless to say it did not complete the job. I am still looking for other options. Thanks for your post though.
     
    locals, Jun 22, 2013 IP
  4. joshuthomas

    joshuthomas Well-Known Member

    Messages:
    595
    Likes Received:
    9
    Best Answers:
    1
    Trophy Points:
    140
    #4
    oh am sorry about that.. last time when i tried out the plugin it did work for me getting the job done, thats why i recommended. Do you mind showing the link to the website so that I could take a look at the contact form and what exactly is required. If the Page Title for the contact form is showing some PHP code then there is some error, you might want to check either the page template file or the contact form / plugin or page (depends on how this was created on WP).
     
    joshuthomas, Jun 22, 2013 IP
  5. iulian.pw

    iulian.pw Active Member

    Messages:
    71
    Likes Received:
    3
    Best Answers:
    2
    Trophy Points:
    65
    #5
    The problem is you are inside a php string and you are including another php start and end. Just change to this and let me know if it works.

      <textarea name="cuf_msg'.$n.'" id="cuf_msg'.$n.'" class="cuf_textarea" cols="50" rows="10">'.$cuf_msg.'I am interested in '.the_title().'</textarea>
    Code (markup):
     
    iulian.pw, Jun 22, 2013 IP
  6. locals

    locals Well-Known Member

    Messages:
    1,677
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    153
    #6
    This didn't work, it was just a blank spot where the title should've been
     
    locals, Jun 22, 2013 IP
  7. locals

    locals Well-Known Member

    Messages:
    1,677
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    153
    #7
    Here is the link to the contact form I am using
    http://wordpress.org/plugins/sidebar-form/
     
    locals, Jun 22, 2013 IP
  8. iulian.pw

    iulian.pw Active Member

    Messages:
    71
    Likes Received:
    3
    Best Answers:
    2
    Trophy Points:
    65
    #8

    Try:
    <textarea name="cuf_msg'.$n.'" id="cuf_msg'.$n.'" class="cuf_textarea" cols="50" rows="10">'.$cuf_msg.'I am interested in '.single_post_title().'</textarea>
    Code (markup):
    If this does not work you should try this:
     $postTitle = single_post_title();
    <textarea name="cuf_msg'.$n.'" id="cuf_msg'.$n.'" class="cuf_textarea" cols="50" rows="10">'.$cuf_msg.'I am interested in '.$postTitle.'</textarea>
    Code (markup):
     
    iulian.pw, Jun 22, 2013 IP
  9. locals

    locals Well-Known Member

    Messages:
    1,677
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    153
    #9

    Okay the first one didn't work, but I am going to try the second one but where should I add the
    $postTitle = single_post_title();
    Code (markup):
    Should I place it right above there or some where in the top of the page?
     
    locals, Jun 22, 2013 IP
  10. iulian.pw

    iulian.pw Active Member

    Messages:
    71
    Likes Received:
    3
    Best Answers:
    2
    Trophy Points:
    65
    #10
    Just add it after this:
    $cuf_sender = (isset($_POST['cuf_sender'.$n])) ? $_POST['cuf_sender'.$n] : ''; 
    		$cuf_email = (isset($_POST['cuf_email'.$n])) ? $_POST['cuf_email'.$n] : '';
    		$cuf_msg = (isset($_POST['cuf_msg'.$n])) ? $_POST['cuf_msg'.$n] : '';
    Code (markup):
    You can find it above the line where you are trying to insert the title.
     
    iulian.pw, Jun 22, 2013 IP
  11. locals

    locals Well-Known Member

    Messages:
    1,677
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    153
    #11
    Okay so I added the two lines of code. It displayed the title, but not in the input box. and also kept repeating itself. It displayed the title in the top of the entire contact form and repeated itself 2 or 3 times. Thanks for your continued help with this
     
    locals, Jun 22, 2013 IP
  12. iulian.pw

    iulian.pw Active Member

    Messages:
    71
    Likes Received:
    3
    Best Answers:
    2
    Trophy Points:
    65
    #12
    I see, I have installed the plugin on one of my WP sites and finally found what to do:

    Change to this:
    $postTitle = get_the_title($post->post_parent);
    Code (markup):
    <textarea name="cuf_msg'.$n.'" id="cuf_msg'.$n.'" class="cuf_textarea" cols="50" rows="10">'.$cuf_msg.' I am interested in '.$postTitle.'</textarea>
    Code (markup):
    If you want to add this to the widget in sidebar you add the same lines inside:
    function showFormWidget( $params = '' )
    {
    ....
    }
    Code (markup):
     
    iulian.pw, Jun 22, 2013 IP