Reputation: 33
Array (
[330] => WP_Post Object (
[ID] => 330
[post_author] => 1
[post_date] => 2019-02-01 21:01:54
[post_date_gmt] => 2019-02-01 21:01:54
[post_content] =>
[post_title] => wordpress-4.9.8
[post_excerpt] =>
[post_status] => inherit
[comment_status] => open
[ping_status] => closed
[post_password] =>
[post_name] => wordpress-4-9-8
[to_ping] =>
[pinged] =>
[post_modified] => 2019-02-01 21:01:54
[post_modified_gmt] => 2019-02-01 21:01:54
[post_content_filtered] =>
[post_parent] => 329
[guid] => http://localhost:8080/brainwise/wp-content/uploads2019/02/wordpress-4.9.8.zip
[menu_order] => 0
[post_type] => attachment
[post_mime_type] => application/zip
[comment_count] => 0
[filter] => raw
)
)
I am using WordPress and I have the following Object Array from my post table and I want to extract guid
element of this array.
How do I extract this?
Upvotes: 0
Views: 370
Reputation: 51
get the key then the object inside it
<p>echo $array_name[array_keys($array_name)[0]]->{guid};</p>
Upvotes: 0
Reputation: 570
Just use get_the_guid( $post->ID );
.
See: https://developer.wordpress.org/reference/functions/get_the_guid/
Upvotes: 1