I bought a simple plugin to show the last several posts from a particular category. I'm not happy with the way the post meta is displayed so I'm trying to customise it manually. The code I suspect needs to change is:
if ( $show_date or $show_comments ) {
$html .= '<div class="cp-details">';
if ( $show_date )
$html .= '<a class="cpw-date" href="' . get_permalink( $post->ID ). '">' . mysql2date( $date_format , $post->post_date, false) . '</a>';
if ( $show_comments )
$html .= '<a class="cpw-comments" href="' . get_comments_link( $post->ID ) . '">' . get_comments_number( $post->ID ) . '</a>';
$html .= '</div >';
}
All I want to do is have a line below the post title as follows:
"Posted by [author first name] on [j F] | [# of comments/link to comments] comments | Permalink"
I've tried the following code which did not work...
if ( $show_date or $show_comments ) {
$html .= "<div class='cp-details'>";
$html .= "<span class='cpw-meta'>" . get_the_time( $post->ID, 'j F') . "</span>";
$html .= "</div >";
}
The site is www.teaminfocus.com.au... login available on request.
Can anyone help?
Arnav Joy answers:
try this
<?php
if ( $show_date or $show_comments ) {
$num_comments = get_comments_number();
if ( comments_open() ) {
if ( $num_comments == 0 ) {
$comments = __('No Comments');
} elseif ( $num_comments > 1 ) {
$comments = $num_comments . __(' Comments');
} else {
$comments = __('1 Comment');
}
$write_comments = '<a href="' . get_comments_link() .'">'. $comments.'</a>';
}
$html .= "<div class='cp-details'>";
$html .= "Posted by ".get_the_author()." on <span class='cpw-meta'>" . get_the_time( $post->ID, 'j F') . "</span> | ".$write_comments." ";
$html .= "</div >";
}
Jason Harris comments:
Looks like it's working.
This is the output from that code... any idea why the date is coming out in that format?