php WPForms:使用自定义值处理自己的智能标记(smarttag)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php WPForms:使用自定义值处理自己的智能标记(smarttag)相关的知识,希望对你有一定的参考价值。

<?php

add_filter( 'wpforms_smart_tag_process', function ( $content, $tag ) {

	// CHANGE custom_tag TO YOUR OWN SMART TAG NAME.
	preg_match_all( '/custom_tag="(.+?)"/', $tag, $ids );

	if ( ! empty( $ids[1] ) ) {
		foreach ( $ids[1] as $key => $item_id ) {
			// CHANGE HERE WHAT YOU WANT TO GET.
			$value = get_post_field( 'post_title', (int) $item_id );
			//$value = get_post_meta( (int) $item_id, '_amount', true );

			$content = str_replace( '{custom_tag="' . $item_id . '"}', $value, $content );
		}
	}

	return $content;
}, 10, 2 );

以上是关于php WPForms:使用自定义值处理自己的智能标记(smarttag)的主要内容,如果未能解决你的问题,请参考以下文章