过滤 post 对象 ACF 上的某些数据
Filter certain data on post object ACF
想问
我有使用 post 对象的 ACF 字段。我想使用 url 从 post 对象字段发送值。结果显示它发送了所有详细信息。
我做的是:
$field['choices'] = array();
$choices = get_field('t2_first_name',$post->ID);
$query = http_build_query(array('aParam' => $choices));
$cpage = home_url('/?datasend='.$query);
//button to send data in url
echo '<a class="cst-btn cst-btn-'.$color.'" href="'.$cpage.'" >Submit</a>';
结果显示:
{"post_author":"3998","post_date":"2020-04-05 05:23:10","post_date_gmt":"2020-04-04 21:23:10","post_content":"","post_title":"183303P","post_excerpt":"","post_status":"publish","comment_status":"closed","ping_status":"closed","post_password":"","post_name":"183303p","to_ping":"","pinged":"","post_modified":"2020-04-05 05:23:10","post_modified_gmt":"2020-04-04 21:23:10","post_content_filtered":"","post_parent":"0","guid":"http:\/\/www.mekcas.a2hosted.com\/trainer\/183303p\/","menu_order":"0","post_type":"trainer","post_mime_type":"","comment_count":"0","filter":"raw"}
如何使用 url 仅过滤 "post_title" 发送?有人可以帮忙吗?
我找到了解决方案:
if( $post_object ):
$name = get_the_title($post_object->ID);
wp_reset_postdata();
endif;
这对我有用。它仅过滤 post_object 的标题(基于所选的 ACF 字段)
想问
我有使用 post 对象的 ACF 字段。我想使用 url 从 post 对象字段发送值。结果显示它发送了所有详细信息。
我做的是:
$field['choices'] = array();
$choices = get_field('t2_first_name',$post->ID);
$query = http_build_query(array('aParam' => $choices));
$cpage = home_url('/?datasend='.$query);
//button to send data in url
echo '<a class="cst-btn cst-btn-'.$color.'" href="'.$cpage.'" >Submit</a>';
结果显示:
{"post_author":"3998","post_date":"2020-04-05 05:23:10","post_date_gmt":"2020-04-04 21:23:10","post_content":"","post_title":"183303P","post_excerpt":"","post_status":"publish","comment_status":"closed","ping_status":"closed","post_password":"","post_name":"183303p","to_ping":"","pinged":"","post_modified":"2020-04-05 05:23:10","post_modified_gmt":"2020-04-04 21:23:10","post_content_filtered":"","post_parent":"0","guid":"http:\/\/www.mekcas.a2hosted.com\/trainer\/183303p\/","menu_order":"0","post_type":"trainer","post_mime_type":"","comment_count":"0","filter":"raw"}
如何使用 url 仅过滤 "post_title" 发送?有人可以帮忙吗?
我找到了解决方案:
if( $post_object ):
$name = get_the_title($post_object->ID);
wp_reset_postdata();
endif;
这对我有用。它仅过滤 post_object 的标题(基于所选的 ACF 字段)