回显数组值三层深(acf 和 wordpress)
Echo array value three levels deep (acf and wordpress)
我正在尝试从使用 ACF http://www.advancedcustomfields.com/resources/post-object/
时生成的 post_objects 数组中获取一些值
这是我的数组:
Array ( [team_member] => WP_Post Object ( [ID] => 57 [post_author] => 2 [post_date] => 2015-05-26 14:41:04 [post_date_gmt] => 2015-05-26 14:41:04 [post_content] => Lorem ipsum dolor sit amet, consectetur adipiscing elit. Illa tamen simplicia, vestra versuta. In his igitur partibus duabus nihil erat, quod Zeno commutare gestiret. Duo Reges: constructio interrete. Idcirco enim non desideraret, quia, quod dolore caret, id in volupta [post_title] => Jeffery Simms [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => jeffery-simms [to_ping] => [pinged] => [post_modified] => 2015-05-26 14:41:04 [post_modified_gmt] => 2015-05-26 14:41:04 [post_content_filtered] => [post_parent] => 0 [guid] => http://mbp.local:5757/?post_type=team_members&p=57 [menu_order] => 0 [post_type] => team_members [post_mime_type] => [comment_count] => 0 [filter] => raw ) )
我正在寻找开始的帖子标题,但还需要特色图片。我试图像这样回应所需的值:
<?php echo$team_members[0][team_member][post_title]; ?>
但是我得到一个错误:
Fatal error: Cannot use object of type WP_Post as array
有什么想法吗?
要访问对象属性,请使用 ->
而不是 []
。
我正在尝试从使用 ACF http://www.advancedcustomfields.com/resources/post-object/
时生成的 post_objects 数组中获取一些值这是我的数组:
Array ( [team_member] => WP_Post Object ( [ID] => 57 [post_author] => 2 [post_date] => 2015-05-26 14:41:04 [post_date_gmt] => 2015-05-26 14:41:04 [post_content] => Lorem ipsum dolor sit amet, consectetur adipiscing elit. Illa tamen simplicia, vestra versuta. In his igitur partibus duabus nihil erat, quod Zeno commutare gestiret. Duo Reges: constructio interrete. Idcirco enim non desideraret, quia, quod dolore caret, id in volupta [post_title] => Jeffery Simms [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => jeffery-simms [to_ping] => [pinged] => [post_modified] => 2015-05-26 14:41:04 [post_modified_gmt] => 2015-05-26 14:41:04 [post_content_filtered] => [post_parent] => 0 [guid] => http://mbp.local:5757/?post_type=team_members&p=57 [menu_order] => 0 [post_type] => team_members [post_mime_type] => [comment_count] => 0 [filter] => raw ) )
我正在寻找开始的帖子标题,但还需要特色图片。我试图像这样回应所需的值:
<?php echo$team_members[0][team_member][post_title]; ?>
但是我得到一个错误:
Fatal error: Cannot use object of type WP_Post as array
有什么想法吗?
要访问对象属性,请使用 ->
而不是 []
。