【发布时间】:2012-11-15 07:03:14
【问题描述】:
我使用一个在 content.php 页面上生成缩略图的模板,如下所示:
<article <?php post_class('single-entry clearfix'); ?>>
<?php
// Test if post has a featured image
if( has_post_thumbnail() ) {
// Get resize and show featured image : refer to functions/img_defaults.php for default values
$wpex_entry_img = aq_resize( wp_get_attachment_url( get_post_thumbnail_id(), 'full' ), wpex_img( 'blog_entry_width' ), wpex_img( 'blog_entry_height' ), wpex_img( 'blog_entry_crop' ) );
?>
<div class="single-entry-thumbnail">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img src="<?php echo $wpex_entry_img; ?>" alt="<?php echo the_title(); ?>" /></a>
</div><!-- /single-entry-thumbnail -->
<?php } ?>
<div class="entry-text clearfix">
<header>
<h3><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
</header>
</div><!-- /entry-text -->
我刚开始使用 Wordpress 和 php,我想为此添加一个参数,因此只有类别为“展示”的帖子才会显示。任何人的想法?
【问题讨论】:
-
您需要在帖子查询中添加一个参数,该参数发生在您共享的代码之上或之前。你能找到任何相关的
query_posts、WP_Query或get_posts粘贴到这里吗? -
感谢@crowjonah 调查它。这就是我遇到的问题。此代码似乎与“典型”WP 循环不同。此 .php 文件或其他 .php 文件中没有此类参数。
标签: php wordpress filter categories posts