字preSS数组以显示某些类别和展后摘录职位和功能部件ING [英] Wordpress array to show post from certain category and show post excerpt and feature ing

查看:217
本文介绍了字preSS数组以显示某些类别和展后摘录职位和功能部件ING的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好寻找一个字preSS帮助。我需要把一个简单的查询/阵列从某个猫例如新闻,其中将包括岗位特色的图像显示的帖子。

Hi all looking for a Wordpress help. I need to place a simple query/array to display posts from a certain cat e.g "News' that will include the posts featured image.

任何人都可以请帮助?

加里

推荐答案

不要使用query_posts()。其意图是修改默认字preSS循环,而不应被用于一般的查询。使用 WP查询或的获取帖子的吧。

Don't use query_posts(). Its intention is to modify the default Wordpress Loop, and should not be used for general queries. Use WP Query or Get Posts instead.

下面是关于邮政缩略图

下面是根据什么你告诉我可能工作的一个小例子。请注意,showposts已改为posts_per_page',为'showposts是pcated为2.1版本德$ P $:

Here's a small example based on what you showed me that might work. Notice that 'showposts' has been changed to 'posts_per_page', as 'showposts' was deprecated as of version 2.1:

<?php
$q = new WP_Query(array('cat'=>8, 'posts_per_page'=>4));
if($q->have_posts()) : while($q->have_posts()) : $q->the_post();
    the_excerpt();
    if(has_post_thumbnail())
        the_post_thumbnail('thumbnail');
endwhile;endif;
?>

更新:

根据你给我的例子,这应该让你开始:

Based on the example you gave me, this should get you started:

<div id="slider2">
<div class="viewport">
    <?php
    $q = new WP_Query(array('cat'=>8, 'posts_per_page'=>4));
    if($q->have_posts()) : while($q->have_posts()) : $q->the_post();
    ?>
    <div class="newsPost">
        <div class="news-date"><?php the_date(); ?></div>
        <div class="newstitle"><?php the_title(); ?></div>
        <div class="news-des"><?php the_excerpt(); ?></div>
        <?php if(has_post_thumbnail()){ ?>
        <div class="newsimg"><?php the_post_thumbnail(); ?></div>
        <?php } ?>
        <p><a href="<?php the_permalink(); ?>">Read More...</a></p>
    </div>
    <?php endwhile;endif; ?>   
</div>
</div>​

这篇关于字preSS数组以显示某些类别和展后摘录职位和功能部件ING的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆