首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >面包屑痕迹显示不正确的痕迹?

面包屑痕迹显示不正确的痕迹?
EN

Stack Overflow用户
提问于 2013-09-01 20:04:03
回答 1查看 135关注 0票数 0

为什么下面的代码会导致我的面包屑路径在面包屑中显示相同的post链接,而不管您在站点上的是哪个页面?

我被困在这个问题上已经很久了,我就是想不出.

明白我的意思了,这里

代码语言:javascript
复制
<!-- Loops through Stories and returns images -->

    <ul style="width: 1520px">                                    
    <?php
        global $post;
            $category_id = get_cat_ID('stories');
            $args = array( 'numberposts' => 9, 'offset'=> 0, 'category'=> $category_id );
            $myposts = get_posts( $args );
        foreach( $myposts as $post ) : setup_postdata($post); ?>
            <!-- stories -->   
            <li>
                <figure>
                      <?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>    
                    <a href="<?php the_permalink(); ?>">
                    <?php the_post_thumbnail(array(64,64)); // Declare pixel size you need inside the array ?></a>
                <?php endif; ?>
                </figure>
                <!-- /post thumbnail -->
                <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
          </li>
<?php endforeach; ?>
         </ul> 
<!-- /Loops through Stories and returns images -->
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-01 20:26:19

尝试重置后数据,如在这个例子来自“法典”

代码语言:javascript
复制
<ul>
<?php
global $post;
$args = array( 'numberposts' => 5, 'offset'=> 1, 'category' => 1 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) :
  setup_postdata($post); ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; 
wp_reset_postdata(); ?>
</ul>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18562368

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档