WordPress.org

Forums

Contextual Related Posts
[resolved] Add date beside post title (9 posts)

  1. anhtuan020588
    Member
    Posted 1 year ago #

    Hello,

    I've tried add date beside post title by using these code below but it does not display date based on post_date anymore, it's just display today (screenshot http://img209.imageshack.us/img209/8713/57201384357am.jpg):

    $output .= '<label style="color:#888888;font-size:11px;padding-top:2px;font-style:italic;"> (' . date_format(date_create($search->post_date),"d/m/Y") . ') </label>';

    and

    $output .= '<label style="color:#888888;font-size:11px;padding-top:2px;font-style:italic;"> (' . mysql2date("d/m/Y", $related_post->post_date) . ') </label>';

    and

    $output .= '<label style="color:#888888;font-size:11px;padding-top:2px;font-style:italic;"> (' . $related_post->post_date . ') </label>';

    My URL http://www.nhadep.net/vi/12/2012/18-kieu-phong-khach-hien-dai/

    Could you please help me correct it?

    Thanks,
    Tuan.

    http://wordpress.org/extend/plugins/contextual-related-posts/

  2. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    Tuan,

    Appreciate if you could wrap your code above in code tags. Am a bit confused on what exactly you're changing.

  3. anhtuan020588
    Member
    Posted 1 year ago #

    I've tried three codes below:
    1.
    $output .= '<label style="color:#888888;font-size:11px;padding-top:2px;font-style:italic;"> (' . date_format(date_create($search->post_date),"d/m/Y") . ') </label>';

    2.
    $output .= '<label style="color:#888888;font-size:11px;padding-top:2px;font-style:italic;"> (' . mysql2date("d/m/Y", $related_post->post_date) . ') </label>';

    3.
    $output .= '<label style="color:#888888;font-size:11px;padding-top:2px;font-style:italic;"> (' . $related_post->post_date . ') </label>';

  4. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    You need to modify the plugin and add the code before line 126 of https://plugins.trac.wordpress.org/browser/contextual-related-posts/trunk/contextual-related-posts.php

    $output .= '<span class="crp_date"> '.mysql2date("d/m/y", $result->post_date).'</span>';

    However, please note that it is not recommended to modify the plugin files directly since it will most likely break in the next upgrade

  5. anhtuan020588
    Member
    Posted 1 year ago #

    Thanks for your help. I tried to add your code but the date still not showing.

  6. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    You also need to add this code

    $result = get_post($result->ID);

    after this on line 101

    foreach($results as $result) {
  7. anhtuan020588
    Member
    Posted 1 year ago #

    Works like charm :) Thank you so much.

  8. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    You're welcome. I've put the date showing in my list of things to add to the plugin. So, the next time around you should be able to upgrade and turn the option on.

  9. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    This has been implemented the date feature in v1.8.8 that I released today. You choose to tick or untick this display in the Settings page

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.