Search code examples
wordpresswordpress-theminggravity-forms-plugingravityforms

how to add gravity forms to blog page(posts page) in WordPress


I using gravity forms plugin and I want to add a form in my blog page(posts page) but on the page editor, I can't add gravity form in the content.

Or I need to show the form where I need it, not in the content of the post or page

my problems are:

  1. I can't(don't know how to) show the form where I want
  2. I can't show my form inside blog page(posts page)

my index.php and single.php files code:

<?php
get_header();
if(have_posts()):
    while(have_posts()): the_post(); ?>
        <article class="post page">
            
            <h2><?php the_title(); ?></h2>
            <?php the_content(); ?>
        </article>
    <?php endwhile;
else:
    echo '<p>No Content Found!</p>';
endif; ?>

 <div class="gravity-form-place">
    <!-- gravity form must show here -->
 </div>
<?php get_footer(); ?>

how to show the forms inside <div class="gravity-form-place"> in the single.php file ?

how to show the forms inside <div class="gravity-form-place"> in the index.php file blog page(posts page)?


Solution

  • Have you tried to use Gravity Form shortcode? If you haven't, try it. Here's the documentation:

    Creating a Form Shortcode - Gravity Form

    It should be something like this:

    <?php 
    
        echo do_shortcode( '[gravityform id="1"]' );
    
     ?>