【问题标题】:Wordpress - Calling on Posts From Different Categories Through a SliderWordpress - 通过滑块调用来自不同类别的帖子
【发布时间】:2014-07-04 02:09:23
【问题描述】:

希望有人可以帮助我,我已经为此苦苦挣扎了好几天,试图找到答案......

基本上,我有一个 wordpress 网站,它有一个滑块(不是插件,只是开源代码),它被称为使用“get_template”,但它在每个页面上显示相同的三个帖子。我在不同类别中有不同的帖子,并希望滑块在每个单独的页面上对应并回显每个特定类别的帖子。


<div id="slidorion">
<div id="slider">

<?php
query_posts( 'posts_per_page=3' );
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

<div class="slide">"><?php the_post_thumbnail(); ?></div>

<?php endwhile; ?>
<?php endif; ?>

</div>

<div id="accordion">

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

<div class="link-header"><?php the_title(); ?></div>
<div class="link-content">

<?php the_excerpt(); ?>

</div>

<?php endwhile; ?>
<?php endif; ?>

</div>
</div>

如果您需要查看该网站以完全理解我的意思和需要做的事情,这里有一个链接...

http://www.kaijocreative.co.uk/footballnatter

谢谢!

【问题讨论】:

    标签: php wordpress slider posts


    【解决方案1】:

    您应该根据您的确切需要更改您的查询,将catcategory 添加到您的query_posts( 'posts_per_page=3' );

    Query_posts (),也看看WP_Query class

    【讨论】:

      【解决方案2】:

      您需要使用从每个帖子中找出类别 ID,然后在

      中使用这些 ID

      $category = get_the_category();

      $post_catid= $category[0]->term_id;

      $querystr='cat='.$post_catid.'&posts_per_page=3';

      query_posts($querystr);

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-09-02
        • 1970-01-01
        • 2017-04-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多