All Good Things Must Come To An End

As you all know, I have been doing WordPress plugins and supporting it for the past 6 years. These 6 years of my life, I have been through my polytechnic education, my national service as well as my university education.

I just graduated from university in December 2009 and have been looking for full-time jobs. I am offered a full-time job and will be starting work on 1st February 2010.

I regret to say that I am NOT ABLE to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

However, I WILL still update my plugins whenever I can and you still can report bugs to me via email and I will try to fix it.

Author Topic: Relative date  (Read 5418 times)

0 Members and 1 Guest are viewing this topic.

Offline Romik84

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Relative date
« on: 05 February 2007, 14:23 »
Hello, I would like to ask you for help. I use Customizable Post Listing and I would like to show date like relative. It means when I pubilsh a article on the day it will show beside title Today. What shoul I add or change in this code:

Code: [Select]
function c2c_get_recent_posts ($num_posts = 5,
$format = "<li>%post_date%: %post_URL%</li>",
$categories = '', // space separated list of category IDs -- leave empty to get all
$orderby = 'date',
$order = 'DESC', // either 'ASC' (ascending) or 'DESC' (descending)
$offset = 0, // number of posts to skip
$date_format = 'M j', // Date format, php-style, if different from blog's date-format setting
$authors = '', // space separated list of author IDs -- leave empty to get all
$include_passworded_posts = false)
{
global $wpdb, $tablecomments, $tableposts, $tablepost2cat;
if ($add_recent_comment_to_sql && !isset($tablecomments)) $tablecomments = $wpdb->comments;
if (!isset($tablepost2cat)) $tablepost2cat = $wpdb->post2cat;
if (!isset($tableposts)) $tableposts = $wpdb->posts;
if ($order != 'ASC') $order = 'DESC';
if ('max_comment_date' == $orderby) { $add_recent_comment_to_sql = 1; }
else {
if ($orderby != 'rand()') $orderby = "$tableposts.post_$orderby";
$add_recent_comment_to_sql = 0;
}
$include_sticky_posts = true;

$now = current_time('mysql');
if ($add_recent_comment_to_sql) $sql = "SELECT $tableposts.*, MAX(comment_date) AS max_comment_date FROM $tablecomments, $tableposts ";
else $sql = "SELECT DISTINCT * FROM $tableposts ";
if ($categories) {
$sql .= "LEFT JOIN $tablepost2cat ON ($tableposts.ID = $tablepost2cat.post_id) ";
$cats = explode(' ', $categories);
}
$sql .= "WHERE $tableposts.post_date <= '$now' AND $tableposts.post_type = 'post' AND ( $tableposts.post_status = 'publish' ";
if ($include_sticky_posts) $sql .= "OR $tableposts.post_status = 'sticky' ";
$sql .= ") ";
if (!$include_passworded_posts) $sql .= "AND $tableposts.post_password = '' ";
if ($add_recent_comment_to_sql) $sql .= "AND $tableposts.ID = $tablecomments.comment_post_ID AND $tablecomments.comment_approved = '1' ";
if ($categories) {
$first = 1;
$sql .= "AND ( ";
foreach ($cats as $cat) {
if ($first) $first = 0;
else $sql .= "OR ";
$sql .= "$tablepost2cat.category_id = '$cat' ";
}
$sql .= ") ";
}
if ($authors) {
$auths = explode(' ', $authors);
$first = 1;
$sql .= "AND ( ";
foreach ($auths as $author) {
if ($first) $first = 0;
else $sql .= "OR ";
$sql .= "$tableposts.post_author = '$author' ";
}
$sql .= ") ";
}
if ('modified' == $orderby) $sql .= "AND $tableposts.post_modified_gmt <= '$now' ";
$sql .= "GROUP BY $tableposts.ID ORDER BY $orderby $order";
if ($num_posts) $sql .= " LIMIT $offset, $num_posts";
$posts = array();
$posts = $wpdb->get_results($sql);
if (empty($posts)) return;
return c2c_get_recent_handler($posts, $format, $date_format);
} //end function c2c_get_recent_posts()

thanks.  :)

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: Relative date
« Reply #1 on: 05 February 2007, 15:56 »
you may want to try my wp-relativedate plugin to see if it works, id it don't, I do not think I can help you with it because it is quite tedious.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline Ttech

  • Official Support
  • Global Moderator
  • *****
  • Posts: 4,296
    • View Profile
Re: Relative date
« Reply #2 on: 05 February 2007, 23:22 »
...
Learning and Helping one day at a time.




DevNode.org Operator - The IRC network for Programers

Offline Romik84

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Re: Relative date
« Reply #3 on: 06 February 2007, 09:32 »
ok. It works but only in Category template. Isn't there a way how I could modify it? I need add the function to this code:

Code: [Select]
<?php c2c_get_recent_posts(3,"<li>%post_URL% <strong>%post_date%</strong><br /><span class='square'>%post_excerpt_short%</span></li>",1);?>

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: Relative date
« Reply #4 on: 06 February 2007, 09:47 »
modify it? not, it is not that straight forward.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline Romik84

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Re: Relative date
« Reply #5 on: 06 February 2007, 10:39 »
oh ok...so I cant do anything  :(

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: Relative date
« Reply #6 on: 06 February 2007, 11:21 »
yeap

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.