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.

Custom CSS of GF in Custom Post Metabox - not working

  1. sammet

    Hi All!

    I have a Custom Post that I call Books.
    To that custom post Books I have created a Metabox that I call OrderBox.
    To the OrderBox I have added a Text Area Field.
    Into that Text area I insert Gravity Form shortcodes to display different product (Books) forms .

    Then I create Custom Css to style the form.

    My problems:
    Data picker is not working
    Some ready classes are not taking effect

    The strange thing:
    When adding the same or even an another GF, but into the WP main editor - everything is working! The Datepicker shows up and all the Ready classes and CSS are perfect! Both the form in the Metabox AND the form in the WP Main editor are working. They are displayed on the same page.

    But when I delete the GF shortcode from the WP Main Editor, all the styling and the datepicker are gone from the form in the Metabox.

    What is happening here? It should not be a Theme or Plugin conflict, since it is working most of the times or?

    Happy for all help and tips!

    Best regards,

    Posted 10 years ago on Monday September 19, 2011 | Permalink
  2. This is a WordPress issue, not a Gravity Forms issue. The CSS and Javascript for Gravity Forms are not being enqueued when you insert the shortcode into a custom field like that. WordPress only allows you to enqueue scripts and CSS at certain points in the WordPress page execution life cycle.

    If you are going to do this you are going to need to manually enqueue the necessary scripts and CSS for that form by adding the necessary enqueue function calls to your themes functions.php file.

    You can read more about the enqueue function call here:

    Posted 10 years ago on Monday September 19, 2011 | Permalink
  3. sammet

    Hi again Carl!

    Thanks for quick answer. Awesome.

    I tried to do as you suggest. Unfortunately it still does not work.

    However, in your commment you say I should put the code into the functions.php file, while at the documentation page it says in the theme's header.php file just before the wp_head() .

    Which one is the right one? I have tried both. Please, consult my screenshots at

    1. This is how I have inserted the code you gave me. Is this right? Maybe I have placed or written it wrong. Please, look at:

    I was wondering if I should not put the code in the Custom Post php template instead? Just an idea - I am totally unfamiliar with PHP.

    2. This is how it looks when there is only one form in the Metabox.

    3. This is how the form looks like in the Metabox when there are two forms on the same page. One in WP Main Editor and one in the Metabox.

    I hope you can help sorting out some of the doubts ;-)

    Thanks again!

    Best regards,

    Posted 10 years ago on Tuesday September 20, 2011 | Permalink
  4. sammet

    Hi All!

    At the moment I got it working thanks to the comments by member dwenaus

    Is this the right way? If so - I think it would be a good idea to update the documentation so more people will find the solution more easily.

    Please, let me and the rest of community know whats currently right.

    Best regards,

    Posted 10 years ago on Tuesday September 20, 2011 | Permalink
  5. You shouldn't have to wrap it in a function the way the user in that post has done. The enqueue function itself is a function. But the user is correct in wrapping it in an if statement so it only executes the enqueue in certain situations.

    You only want it happening on the page or post you need it to display on, unless it's part of the overall theme design then you can execute it on every page load.

    It sounds like however you had it implemented before wasn't correct and that changing the code to use the other users example corrected whatever you were doing wrong.

    The ideal place for the function call is in your themes functions.php file.

    Posted 10 years ago on Tuesday September 20, 2011 | Permalink

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