php 将Gravity Forms添加到单个AgentPress列表帖子中,并使用帖子标题动态填充表单。将其添加到functions.php中。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 将Gravity Forms添加到单个AgentPress列表帖子中,并使用帖子标题动态填充表单。将其添加到functions.php中。相关的知识,希望对你有一定的参考价值。

<?php //remove this line

/**
 * Enqueue scripts for a specified Gravity Form (13 = ID) and then 
 * embed Gravity Form at the bottom of single property listings 
 * 
 * http://www.gravityhelp.com/documentation/page/Gform_enqueue_scripts 
 * http://www.gravityhelp.com/documentation/page/Embedding_A_Form#Function_Call
 *
 * @author Carrie Dils
 * @link http://www.carriedils.com/
 */

// Add scripts for Gravity Forms with ID 13
gravity_form_enqueue_scripts( 13, true );

// Call function to add form to bottom of the entry
add_action( 'genesis_entry_footer', 'wap_add_contact_form', 5 );

// Return Gravity Form with specified ID to single listing CPT
function wap_add_contact_form() {

	// bail if we aren't on a single listing CPT
	if ( ! is_singular( 'listing' ) ) {
		return;
	}

	// display Gravity Form with ID 13
	gravity_form( 13, true, false, false, '', false );
}
<?php //remove this line

/**
 * Return title of current post for single property listing
 * Dynamic population for Gravity Forms (dynamic population parameter = property_name)
 * http://www.gravityhelp.com/documentation/page/Using_Dynamic_Population
 *
 * @author Carrie Dils
 * @link http://www.carriedils.com/
 */

add_filter( 'gform_field_value_property_name', 'wap_populate_post_title' );
function wap_populate_post_title( $value ) {

	// bail if we aren't on a single listing CPT
	if ( ! is_singular( 'listing' ) ) {
		return;
	}

	// fetch the post title
	$title = get_the_title();

	// return value escaped
	return esc_html( $title );
}

以上是关于php 将Gravity Forms添加到单个AgentPress列表帖子中,并使用帖子标题动态填充表单。将其添加到functions.php中。的主要内容,如果未能解决你的问题,请参考以下文章

php Gravity Wiz // Gravity Forms //将GF数据填充到WP Job Manager自定义字段中

php 将Gravity Forms文件上传发送到Amazon S3

php 从Gravity Forms导出文件中删除空行(导入到excel时出现问题)

Gravity Forms - 将字段条目显示为实时预览

php Gravity Wiz // Gravity Forms Styles Pro //强制验证消息

php Gravity Wiz // Gravity Forms //按表单名称获取表单ID