我创建了一个小部件,显示流行和最近的帖子,但那总是显示 2013 08 02 有什么问题?那用 wp_query 显示正确,但显示更多额外的字符串我无法清除。
function posts($sort = 'recent', $items = 3, $echo = TRUE, $bg_color = 'black')
{ $return_html = '';
if($sort == 'recent')
{
$posts = get_posts('numberposts='.$items.'&order=DESC&orderby=date&post_type=post&post_status=publish');
$title = __('Recent Posts', THEMEDOMAIN);
}
else
{
global $wpdb;
$query = "SELECT ID, post_title, post_content FROM {$wpdb->prefix}posts WHERE post_type = 'post' AND post_status= 'publish' ORDER BY comment_count DESC LIMIT 0,".$items;
$posts = $wpdb->get_results($query);
$title = 'Popular Posts';
}
if(!empty($posts))
{
$return_html.= '<h2 class="widgettitle">'.$title.'</h2>';
$return_html.= '<ul class="posts blog '.$bg_color.'_wrapper">';
$count_post = count($posts);
foreach($posts as $post)
{
$image_thumb = get_post_meta($post->ID, 'blog_thumb_image_url', true);
$return_html.= '<li>';
if(has_post_thumbnail($post->ID, 'large'))
{
$image_id = get_post_thumbnail_id($post->ID);
$image_url = wp_get_attachment_image_src($image_id, 'thumbnail', true);
$return_html.= '<a href="'.get_permalink($post->ID).'"><img class="alignright frame" src="'.$image_url[0].'" alt="" /></a>';
}
$return_html.= '<strong class="title"><a href="'.get_permalink($post->ID).'">'.$post->post_title.'</a></strong><br/><span class="post_attribute">'.get_the_time('F j, Y', $post->ID).'</span>';
$return_html.= '</li>';
}
$return_html.= '</ul>';
谁能帮我?对不起,我的英语不好。