Title: Function call embedding method
Last modified: January 9, 2021

---

# Function call embedding method

 *  Resolved [androweb](https://wordpress.org/support/users/androweb/)
 * (@androweb)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/function-call-embedding-method/)
 * Hi, any plans to include the function call method for embedding in theme files?
 * [https://docs.gravityforms.com/adding-a-form-to-the-theme-file/](https://docs.gravityforms.com/adding-a-form-to-the-theme-file/)
 * Alternatively do you suggest simply adding the following to the relevant theme
   files?
 * `define( 'DONOTCACHEPAGE', true );`
    -  This topic was modified 5 years, 4 months ago by [androweb](https://wordpress.org/support/users/androweb/).

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Samuel Aguilera](https://wordpress.org/support/users/samuelaguilera/)
 * (@samuelaguilera)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/function-call-embedding-method/#post-13887998)
 * There’s no way to specifically detect that the function call is being used. Using
   DONOTCACHEPAGE would do only part of the job that Fresh Forms does, and only 
   for caching methods that support it, many popular caching plugins and hosts don’t
   support it.
 * I have added a new filter to the development version of the plugin that you can
   use to provide a list of post ID’s to Fresh Forms to force Fresh Forms run for
   these posts without the need of doing form detection.
 * If you want to give it a try before the release [download the modified class-fresh-forms-for-gravity.php file](https://plugins.trac.wordpress.org/export/2453375/fresh-forms-for-gravity/trunk/class-fresh-forms-for-gravity.php)
   
   And use it to replace your copy of this file in your installation.
 * This is an example of how to use the filter.
 *     ```
       add_filter( 'freshforms_post_has_gform', 'fffg_fresh_these_posts' );
       function fffg_fresh_these_posts(){
       	// Force Fresh Forms to run for posts with id 1 and 8.
       	return array( 1, 8);
       }
       ```
   
 * I hope that helps.
 *  Thread Starter [androweb](https://wordpress.org/support/users/androweb/)
 * (@androweb)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/function-call-embedding-method/#post-13888068)
 * Thanks very much, that’s really helpful to know going forward. Is there a filter
   planned for categories and tags? basically I have several hundred product pages
   with embedded forms via function call, that I want to exclude from caching.
 * Alternatively, at mo I’m planning to use WP Super Cache, and possibly Cloudflare
   CDN for files only. So bearing that in mind would the alternative approach I 
   mentioned above work?
    -  This reply was modified 5 years, 4 months ago by [androweb](https://wordpress.org/support/users/androweb/).
 *  Plugin Author [Samuel Aguilera](https://wordpress.org/support/users/samuelaguilera/)
 * (@samuelaguilera)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/function-call-embedding-method/#post-13888876)
 * You can use the same filter to cover categories, tags or any other thing related
   to the post (of any type) that you want to take into consideration to exclude
   your posts. All that you need to do is to create your own PHP code to do whatever
   checks you want and return an array with the post ID(s) to exclude.
 * Here’s another example that would exclude any WooCommerce product that has a 
   product category with the slug product-category-1
 *     ```
       add_filter( 'freshforms_post_has_gform', 'fffg_fresh_these_products' );
       function fffg_fresh_these_products( $post_has_form ){
       	global $post;
   
       	// Run Fresh Forms for a WooCommerce product if it has one of the following categories slugs.
       	$product_categories = array( 'product-category-1' );
       	if ( is_object( $post ) && 'product' === $post->post_type && has_term( $product_categories, 'product_cat', $post->ID ) ) {
       		return array( $post->ID );
       	}
   
       	// Otherwise.
       	return $post_has_form;
       }
       ```
   
 *  Thread Starter [androweb](https://wordpress.org/support/users/androweb/)
 * (@androweb)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/function-call-embedding-method/#post-13889000)
 * Great, thanks for your help.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Function call embedding method’ is closed to new replies.

 * ![](https://ps.w.org/fresh-forms-for-gravity/assets/icon-256x256.jpg?rev=2170847)
 * [Fresh Forms for Gravity](https://wordpress.org/plugins/fresh-forms-for-gravity/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/fresh-forms-for-gravity/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/fresh-forms-for-gravity/)
 * [Active Topics](https://wordpress.org/support/plugin/fresh-forms-for-gravity/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/fresh-forms-for-gravity/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/fresh-forms-for-gravity/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [androweb](https://wordpress.org/support/users/androweb/)
 * Last activity: [5 years, 4 months ago](https://wordpress.org/support/topic/function-call-embedding-method/#post-13889000)
 * Status: resolved