我需要一个小部件,显示以下相关帖子
帖子标题缩略图最好按类别显示相关帖子。
到目前为止,我尝试了这些小部件,它们部分工作或不工作(使用WP v3.3):
Partly working:
- “按类别列出的相关链接”:有效,但没有缩略图;“按相同类别列出的帖子”窗口小部件:有效,但没有缩略图“按相同类别列出的帖子窗口小部件”:有效,但没有缩略图Not working:
“YARPP-又一个相关帖子插件”:显示,但没有相关内容
我需要一个小部件,显示以下相关帖子
帖子标题缩略图最好按类别显示相关帖子。
到目前为止,我尝试了这些小部件,它们部分工作或不工作(使用WP v3.3):
Partly working:
“YARPP-又一个相关帖子插件”:显示,但没有相关内容
假设您乐于接受包含您在"Partly woking:" 标题
Widgets of Posts by Same Categories
http://svn.wp-plugins.org/widgets-of-posts-by-same-categories/trunk/widgets-of-posts-by-same-categories.php
只需要1到2行代码,这取决于您想要如何处理“post没有缩略图”场景。
插件文件的此区域周围。。
<?php
$postslist = get_posts("category=$cat_ID&numberposts=$numberposts&orderby=$orderby&order=$order&exclude=$exclude_posts");
foreach ( $postslist as $post ) :
?>
<li><a href="<?php print get_permalink($post->ID); ?>" title="<?php print get_the_title($post->ID); ?>"><?php print get_the_title($post->ID); ?></a></li>
<?php endforeach; ?>
您所需要添加的是has_post_thumbnail
codex page.if( has_post_thumbnail() )
the_post_thumbnail();
例如。。<?php
$postslist = get_posts("category=$cat_ID&numberposts=$numberposts&orderby=$orderby&order=$order&exclude=$exclude_posts");
foreach ( $postslist as $post ) :
?>
<li>
<?php
if( has_post_thumbnail() )
the_post_thumbnail();
?>
<a href="<?php print get_permalink($post->ID); ?>" title="<?php print get_the_title($post->ID); ?>"><?php print get_the_title($post->ID); ?></a></li>
<?php endforeach; ?>
虽然我想这取决于您希望实现的具体工作方式。。这有帮助吗?:)
我需要一个小部件,显示以下相关帖子
帖子标题缩略图最好按类别显示相关帖子。
到目前为止,我尝试了这些小部件,它们部分工作或不工作(使用WP v3.3):
Partly working:
“YARPP-又一个相关帖子插件”:显示,但没有相关内容
假设您乐于接受包含您在"Partly woking:" 标题
Widgets of Posts by Same Categories
http://svn.wp-plugins.org/widgets-of-posts-by-same-categories/trunk/widgets-of-posts-by-same-categories.php
只需要1到2行代码,这取决于您想要如何处理“post没有缩略图”场景。
插件文件的此区域周围。。
<?php
$postslist = get_posts("category=$cat_ID&numberposts=$numberposts&orderby=$orderby&order=$order&exclude=$exclude_posts");
foreach ( $postslist as $post ) :
?>
<li><a href="<?php print get_permalink($post->ID); ?>" title="<?php print get_the_title($post->ID); ?>"><?php print get_the_title($post->ID); ?></a></li>
<?php endforeach; ?>
您所需要添加的是has_post_thumbnail
codex page.if( has_post_thumbnail() )
the_post_thumbnail();
例如。。<?php
$postslist = get_posts("category=$cat_ID&numberposts=$numberposts&orderby=$orderby&order=$order&exclude=$exclude_posts");
foreach ( $postslist as $post ) :
?>
<li>
<?php
if( has_post_thumbnail() )
the_post_thumbnail();
?>
<a href="<?php print get_permalink($post->ID); ?>" title="<?php print get_the_title($post->ID); ?>"><?php print get_the_title($post->ID); ?></a></li>
<?php endforeach; ?>
虽然我想这取决于您希望实现的具体工作方式。。这有帮助吗?:)