0

i'm using 'get_post_date() to show the date in every post preview in my home page. My only problem is that this comand returns me the pubblication date of the page and not of the pubblication date of the post. I tried the same comand in the post page and the result is correct. How can I do to display the right date?

<?php
$block = $block_data[0];
$settings = $block_data[1];
?>
<?php if($block === 'title'): ?>

<div class="blocchetto"></div>
<div style="font-family: 'Prata',serif;font-size: 12px; margin-bottom:2px">
<?php echo get_the_date("d.m.Y",$post->ID); ?> </div>
<h2 class="post-title">
    <?php echo !empty($settings[0]) && $settings[0]!='no_link' ? $this->getLinked($post, $post->title, $settings[0], 'link_title') : $post->title ?>
</h2>

<?php elseif($block === 'image' && !empty($post->thumbnail)): ?>

<div class="post-thumb">
    <?php echo !empty($settings[0]) && $settings[0]!='no_link' ? $this->getLinked($post, $post->thumbnail, $settings[0], 'link_image') : $post->thumbnail ?>
</div>

<?php elseif($block === 'text'): ?>

<div class="entry-content">
    <?php echo !empty($settings[0]) && $settings[0]==='text' ?  $post->content : $post->excerpt; ?>
</div>
<?php elseif($block === 'link'): ?>

<div>
<a href="<?php echo $post->link ?>" id="vc_read_more" class="vc_read_more" title="<?php echo esc_attr(sprintf(__( 'Permalink to %s', "js_composer" ), $post->title_attribute)); ?>"<?php echo $this->link_target ?>><?php _e('Read more...', "js_composer") ?></a>



</div>



<?php endif; ?>
  • since when does `get_the_date` expect two parameters? -> http://codex.wordpress.org/Function_Reference/get_the_date#Parameters – VF_ May 08 '14 at 09:35

1 Answers1

0

Get date using this one

<?php echo $post->post_date; ?>

    WP_Post Object
    (
        [ID] => 1
        [post_author] => 1
        [post_date] => 2014-05-31 10:11:20
        [post_date_gmt] => 2014-05-31 10:11:20
        [post_content] => Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!dsadadsdasdasdsdadasdsadasdasdarvi
        [post_title] => Hello world! 
        [post_excerpt] => this is a excerpt.ravi
        [post_status] => future
        [comment_status] => open
        [ping_status] => open
        [post_password] => 
        [post_name] => hello-world
        [to_ping] => 
        [pinged] => 
        [post_modified] => 2014-05-08 11:56:31
        [post_modified_gmt] => 2014-05-08 11:56:31
        [post_content_filtered] => 
        [post_parent] => 0
        [guid] => http://192.168.1.11/soci39/?p=1
        [menu_order] => 0
        [post_type] => post
        [post_mime_type] => 
        [comment_count] => 1
        [filter] => raw
    )
Ravi Patel
  • 5,121
  • 2
  • 25
  • 44