wordpress - 过滤帖子对象 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 字段)
推荐阅读
- python - 如何使用数据列表而不是行来抓取维基百科表格?
- python - 日月提取熊猫python
- css - 运行 npx tailwindcss init -p 命令时找不到模块“autoprefixer”
- r - 是否可以在 R 中使用 plotly 在悬停信息中显示一个图?
- sql - ORA-00928: 引用其他表时缺少 SELECT 关键字
- javascript - 预期 null 深度等于 [Array (1)]
- python - Django API 自定义喉咙
- powershell - 从文件夹中的所有文件夹名称中删除某些字符
- java - 使用 JsonPath 如何获取这些 json 对象的内部值
- javascript - 为什么我的图像路径不起作用?