对于一些PHP代码有一点问题,我在PHP方面的技能并不是最强的,而且我现在有点陷入困境。
我正在使用新闻页面帖子的网站上工作。 我们正在构建一个blg页面,我也希望使用帖子,使用户更简单,但是我似乎无法让页面只使用一个类别,无论类别如何,它都会拉动每一个帖子。
这是我的页面模板代码。
<div class="container">
<div>
<br /><?php echo pageWidgets($post->ID,'main',400); ?>
</div>
<?php /*?> <div class="contentTop2 newspad">
<?php
$args = array( 'numberposts' => 1,'category_name'=> "blog", 'post_status'=>"publish",'post_type'=>"post",'orderby'=>"post_date");
$postslist = get_posts( $args );
foreach ($postslist as $post) : setup_postdata($post); ?>
<?php $exclude_first_post = $post->ID; ?>
<div class="postNews">
<?php if ( has_post_thumbnail() ) { /* loads the post's featured thumbnail, requires Wordpress 3.0+
echo '<div class="featured-thumbnail">'; the_post_thumbnail(); echo '</div>';
} ?>
<div class="newsRightPost">
<div class="newsTitleTop"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></div>
<div class="newsDateTop">Posted <?php the_date(); ?></div>
<div class="newsExcerptTop"><?php the_excerpt(); ?></div>
<div class="readMoreText"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">Read More >></a></div>
</div>
<div class="clearBoth"> </div>
</div>
<?php endforeach; ?>
<div class="clearBoth"> </div>
</div>
<?php */?>
我认为'category_name'=&gt; “博客”会为我排序,但它似乎根本不起作用。
我获得了博客类别,但我也得到了其他所有类别。
有人能指出我正确的方向吗?
谢谢你们!