Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

do_shortcode doesn't work WordPress

  • SOLVED

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="http://superpositif.com/sites_clients/mediaspectacles/6/"]]http://superpositif.com/sites_clients/mediaspectacles/6/[[/LINK]]

second post :
[[LINK href="http://superpositif.com/sites_clients/mediaspectacles/without-content-in-the-default-visual-editor/"]]http://superpositif.com/sites_clients/mediaspectacles/without-content-in-the-default-visual-editor/[[/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>";
the_title();
echo "</h1>";
echo do_shortcode('[gravityform id="1" name="test"]' );
endwhile; else: endif;
get_footer() ?>

Answers (2)

2014-04-22

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="http://www.gravityhelp.com/documentation/page/Gravity_form_enqueue_scripts"]]http://www.gravityhelp.com/documentation/page/Gravity_form_enqueue_scripts[[/LINK]]


Sébastien | French WordpressDesigner comments:

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

2014-04-22

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 http://www.gravityhelp.com/documentation/page/Shortcodes#Form_Shortcode and Do shortcode documentation http://codex.wordpress.org/Function_Reference/do_shortcode


Hope that helps