Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #902351

    Alex K
    Participant

    Hi, I would like to add the contact form 7 automatically to every post. What would be the way to do it? I suppose altering the functions.php of my child theme?

    Footer contact form doesnt work for me, as I need the info which post the user has seen when writing in.

    Thank You!

    #902367

    Alex K
    Participant

    Preferably I would also like to automatically add a headline above the contact form, if thats possible.

    #902639

    Alex K
    Participant
    This reply has been marked as private.
    #903220

    Friech
    Moderator

    Hi There,

    Thanks for writing in! You can add this on your child theme’s functions.php file.

    /**
    Contact form on every posts
    */
    function contactform_for_every_post( $content ) {
      if ( is_singular('post') ) {
        $contactform = '[contact-form-7 id="109" title="Contact form 1"]';
        echo '<h3>Ich habe Interesse an Tobias</h3>';
        echo do_shortcode($contactform);
      }
    }
    
    add_action('x_before_the_content_end', 'contactform_for_every_post');

    Replace the [contact-form-7 id=”109″ title=”Contact form 1″] with your actual contact form shortcode.

    Hope it helps, Cheers!

    #903593

    Alex K
    Participant

    Thank You. The Contact form was successfully added. But I would like to have it right below the text. Above the share buttons. Also the custom form headline

    So two minor questions are left:

    1. How can I position the contact form above the entry share
    2. Is there a way to use the individual title of each post e.g. “Tobias,37” in the added form headline?

    thank you very much.

    here is my functions.php content as of now

    
    /**
    Contact form on every posts
    */
    function contactform_for_every_post( $content ) {
      if ( is_singular('post') ) {
        $contactform = '[contact-form-7 id="347" title="Kennenlernen"]';
        echo '<h3>Ich habe Interesse</h3>';
        echo do_shortcode($contactform);
      }
    }
    
    add_action('x_before_the_content_end', 'contactform_for_every_post');
    
    /**
    entry share on every post
    */
    add_filter ('the_content', 'entry_share');
    function entry_share ($content) {
    return $content.( is_singular('post') ? '[share title="Weiterempfehlen" facebook="true" twitter="true" google_plus="true"]' : '' );
    }
    
    #904546

    Jade
    Moderator

    Hi Alex,

    Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:

    – Link to your site
    – WordPress Admin username / password
    – FTP credentials

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.