Ask your WordPress questions! Pay money and get answers fast! (more info)

do_shortcode doesn't work WordPress


Hi dear colleagues :-)

I have an enigma for you.
I use Gravity Form 1.8.7

I have no plugins activated, only Gravity Form 1.8.7
My db is virgin. Just two posts for the test and the activation of this plugin.

I created a form, with just one field.
This field uses a mask (99 999).

Both posts display the same form because my template contains the code :
echo do_shortcode('[gravityform id="1" name="test"]' );
IMPORTANT : my template doesn't display the_content

BUT in the first post, the mask works, and in the second post the mask doesn't work !
<strong>Who will know why ? </strong>

I note that in the first post the plugin seems "called" by wp_head, but it seems "called" by wp_footer in the second post (see source)

In my first post, the default visual editor contains this code :
[gravityform id="1" name="test"]
In the second post, I have <strong>no content</strong> in my visual editor.

first post :
[[LINK href=""]][[/LINK]]

second post :
[[LINK href=""]][[/LINK]]

I display my posts with index.php
Here is the code of this index.php :

<?php get_header();
echo "template : index.php ";
if ( have_posts() ) : while ( have_posts() ) : the_post();
echo "<h1>";
echo "</h1>";
echo do_shortcode('[gravityform id="1" name="test"]' );
endwhile; else: endif;
get_footer() ?>

Answers (2)


Kyle answers:

Your two links there don't seem to be working.

I've had issues in the past when echoing GF on custom loops and templates, where the script is not called, or it is called at the wrong time.

Try with the Gravity form enqueue scripts hook in the page header there:

[[LINK href=""]][[/LINK]]

S├ębastien | French WordpressDesigner comments:

It's a perfect response ! Thx.
The problem is resolved.


Ryan S answers:

This is not about the shortcode, this is something on your site where is having a code issue, it only display blank page on my end.

Here are lists of Gravity shortcode you can refer and Do shortcode documentation

Hope that helps