Reputation: 128
I have an array:
//$post array values
Array (
[0] => WP_Post Object ( [ID] => 580 [post_author] => 1 [post_date] => 2017-10-30 15:30:49 [post_date_gmt] => 2017-10-30 14:30:49 [post_content] => [post_title] => 2017-10-30, hétfő [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => 2017-10-30-hetfo [to_ping] => [pinged] => [post_modified] => 2018-01-13 16:05:46 [post_modified_gmt] => 2018-01-13 15:05:46 [post_content_filtered] => [post_parent] => 0 [guid] => http://vegachef.hu/?post_type=etlap&p=580 [menu_order] => 0 [post_type] => etlap [post_mime_type] => [comment_count] => 0 [filter] => raw )
[1] => WP_Post Object ( [ID] => 581 [post_author] => 1 [post_date] => 2017-10-30 15:42:13 [post_date_gmt] => 2017-10-30 14:42:13 [post_content] => [post_title] => 2017-10-31, kedd [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => 2017-10-31-kedd [to_ping] => [pinged] => [post_modified] => 2017-12-26 00:39:41 [post_modified_gmt] => 2017-12-25 23:39:41 [post_content_filtered] => [post_parent] => 0 [guid] => http://vegachef.hu/?post_type=etlap&p=581 [menu_order] => 0 [post_type] => etlap [post_mime_type] => [comment_count] => 0 [filter] => raw )
[2] => WP_Post Object ( [ID] => 762 [post_author] => 4 [post_date] => 2017-12-20 17:48:35 [post_date_gmt] => 2017-12-20 16:48:35 [post_content] => [post_title] => 2017-11-01, szerda [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => 2017-11-01-szerda [to_ping] => [pinged] => [post_modified] => 2018-01-12 01:56:27 [post_modified_gmt] => 2018-01-12 00:56:27 [post_content_filtered] => [post_parent] => 0 [guid] => http://vegachef.hu/?post_type=etlap&p=762 [menu_order] => 0 [post_type] => etlap [post_mime_type] => [comment_count] => 0 [filter] => raw )
[3] => WP_Post Object ( [ID] => 763 [post_author] => 4 [post_date] => 2017-12-20 17:48:59 [post_date_gmt] => 2017-12-20 16:48:59 [post_content] => [post_title] => 2017-11-02, csütörtök [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => 2017-11-02-csutortok [to_ping] => [pinged] => [post_modified] => 2017-12-27 00:21:16 [post_modified_gmt] => 2017-12-26 23:21:16 [post_content_filtered] => [post_parent] => 0 [guid] => http://vegachef.hu/?post_type=etlap&p=763 [menu_order] => 0 [post_type] => etlap [post_mime_type] => [comment_count] => 0 [filter] => raw )
[4] => WP_Post Object ( [ID] => 764 [post_author] => 4 [post_date] => 2017-12-20 17:49:18 [post_date_gmt] => 2017-12-20 16:49:18 [post_content] => [post_title] => 2017-11-03, péntek [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => 2017-11-03-pentek [to_ping] => [pinged] => [post_modified] => 2018-01-10 01:00:06 [post_modified_gmt] => 2018-01-10 00:00:06 [post_content_filtered] => [post_parent] => 0 [guid] => http://vegachef.hu/?post_type=etlap&p=764 [menu_order] => 0 [post_type] => etlap [post_mime_type] => [comment_count] => 0 [filter] => raw ) )
And I have a table as well where I need to write every post_title in the <thead>
<tr>
<td>
's
I made a foreach loop but it returns interesting values:
I don't know why, because my foreach()
loop seems okay to me:
<thead class="first-row-thead">
<tr>
<td id="fist-value-td">
</td>
<?php foreach ($post as $post_title => $get_title): ?>
<td class="dates-container-td">
<div class="dates-container-div">
<h1 class="dates-h1"><?php echo $get_title['post_title']; ?></h1>
</div>
</td>
<?php endforeach; ?>
Upvotes: 0
Views: 58
Reputation: 1
your are missing [post_content] => "value"
this could be a lead to your error .. recheck the associate values in the array
Upvotes: 0
Reputation: 160
Your array seems to be an object, not an array. For objects you need to use:
$get_title->post_title
Edit: Code outputs better
Upvotes: 1