donglanche9257 2018-11-06 11:19
浏览 80

WordPress:获取index.php的内容而不是single.php

the title is fairly self-explanatory.

I click on one of the products and URL is properly changing to /product/product-1/ but the content is still index.php instead of single.php.

so this is the index.php :

<?php get_header(); ?>
<?php View::render('partials/top-bar'); ?>
<?php View::render('partials/header'); ?>
<?php View::render('partials/content'); ?>
<?php get_footer(); ?>

the partial/content is pretty big but this is the logic part of it which has the WordPress loop

<?php
                        $new_products = new WP_Query( array(
                            'post_type' => 'product',
                            'order'     => 'ASC',
                            'orderby'   => 'meta_value_num',
                            'meta_key'  => Product::PRICE_META_KEY,
                        ) );
                    
                    ?>
                    <?php if ( $new_products->have_posts() ): ?>
                        <?php while ( $new_products->have_posts() ): $new_products->the_post(); ?>
                            <div class="spost clearfix">
                                <div class="entry-image">
                                    <a href="<?php echo get_the_permalink(); ?>"><img
                                                src="<?php echo Asset::image( 'shop/small/1.jpg' ); ?>" alt="Image"></a>
                                </div>
                                <div class="entry-c">
                                    <div class="entry-title">
                                        <h4>
                                            <a href="<?php echo get_the_permalink(); ?>"><?php echo get_the_title(); ?></a>
                                        </h4>
                                    </div>
                                    <ul class="entry-meta">
                                        <li class="color"><?php echo Product::price( get_the_ID() ); ?></li>
                                        <li><i class="icon-star3"></i> <i class="icon-star3"></i> <i
                                                    class="icon-star3"></i> <i class="icon-star3"></i> <i
                                                    class="icon-star-half-full"></i></li>
                                    </ul>
                                </div>
                            </div>
                        <?php endwhile; ?>
                    <?php else: ?>
                    <?php endif; ?>

                </div>

single.php has some content but the problem doesn't seem to be related to that, so I didn't include the code here.

Thank you in advance.

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题