PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Gravity form on external wordpress page, not in theme

  1. Hello,

    I'll try keep this short as it's a bit confusing. Any suggestions or advice would be really helpful. I think it's because I don't understand the internals of how these forms submit I can't figure it out. Here it goes...

    I originally had to create a holding page theme. In this holding page theme, I had a gravity form which consisted of a name and email. This form is placed using short code...

    <?php echo do_shortcode('[gravityform id="1" name="Subscribe Newsletter " title="false" description="true" ajax="true"]'); ?>

    But I've now got to convert my holding page theme to a stand alone index.php file which is not a theme. How ever I still need my gravity form on the page.

    This is so I can start building my main theme, and keep the holding page running separate from the wp installation, without actually moving the wp installation.

    So I simply merged my theme header.php, index.php and footer.php into one file (index-temp.php), and I put this index-temp.php into my www root. I then added this php code at the top of the page...

    <?php
    define('WP_USE_THEMES', false);
    require('wp/wp-load.php');
    ?>

    This makes all my wordpress php based code work from the same installation, but as a stand alone file. Non theme based.

    I had to use a cheeky bit of jquery on the stand alone version to change the form action attribute...

    $("#gform_1").attr( "action", "/#gf_1" );

    Please see links below...

    As you can see, the forms on both pages work fine.

    But if I remove the original theme based index.php, the form on the index-temp.php stops working? Nothing happens if you click 'Sign up' - I don't understand why removing the original index.php conflicts with the stand alone index-temp.php version?

    I know it's a little off topic but if you can shed some light that would really helpful.

    Thanks in advance.
    Josh

    Posted 11 years ago on Wednesday June 6, 2012 | Permalink
  2. Josh, I believe this is because WordPress simply requires an index.php file at the root for WordPress to function. What if you named index-temp to index and just kept a backup copy of the original index?

    Then you could place WP in it's own directory while the site is being built:
    http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory

    Notice step 7 in particular.

    Posted 11 years ago on Wednesday June 6, 2012 | Permalink
  3. Hi Rob,

    Appreciate you getting back to me on this.

    Well wordpress will still be functioning, but inside a 'wp' sub-folder. This is where I'll be developing the new website theme.

    My original intention is to change index-temp.php to index.php. This is so it replaces the wordpress version, but mirrors it identically.

    I will do this now so you can see the result. But when doing this, the form becomes dead. You can see the ajax spinning wheel, but nothing happens. But will have to change it back when you've checked it out as it is live. This is the source of my stand alone holding page so you can see the php. This file is totally separate from wordpress but pulls in wordpress content.

    If you can't see the problem then don't worry I'll have do try digging more. But it's weird that it works only whist the original wordpress index file is in place, but does not as soon as I remove the original index file.

    Posted 11 years ago on Wednesday June 6, 2012 | Permalink
  4. Not sure if it would make any difference, but what if you turn off AJAX on the form placement.

    Posted 11 years ago on Wednesday June 6, 2012 | Permalink
  5. Ajax off still same. Though kind of need ajax to be on just for neatness.

    The link below is the index-temp.php non-theme code as posted in my jist.
    http://www.example.co.uk/

    The working theme version is now here in wordpress folder...
    http://www.example.co.uk/wp/

    Posted 11 years ago on Wednesday June 6, 2012 | Permalink
  6. Hi Rob

    Have fixed it.

    Moved the wordpress live file to wp subfolder.

    But just changed my jquery in my stand alone version to...

    $("#gform_1").attr( "action", "/wp/#gf_1" );

    ...and that has sorted the problem. Very confusing.

    Thanks for your time and sorry to mess you about.

    Posted 11 years ago on Wednesday June 6, 2012 | Permalink
  7. Awesome Josh, glad you got it working. No bother here!

    Posted 11 years ago on Wednesday June 6, 2012 | Permalink

This topic has been resolved and has been closed to new replies.