【问题标题】:This loop wouldn't work correctly on the server? [closed]这个循环不能在服务器上正常工作? [关闭]
【发布时间】:2021-01-12 16:07:40
【问题描述】:

我已将此代码添加到 Wordpress 主题的 front-page.php 中,并为相关帖子添加了特色图片,但结果是以下错误消息: 解析错误:语法错误,第 89 行 C:\xampp\htdocs\wordpress\wp-content\themes\Resto 2\front-page.php 中的文件意外结束 您的网站出现严重错误。 这是我要使用的循环

<section id="features">
        <ul>
            <?php /*start the loop*/ ?>
            <?php $myquery = new WP_Query('category_name=menu-items&posts_per_page=4'); ?>
           <!--<?php while ( $myquery->have_posts() ) :  $myquery->the_post(); ?>-->
            <li>
                <?php the_post_thumbnail(); ?>
                <a href="<?php the_permalink() ?> "><?php the_title(); ?><a/>
                <span><?php echo get_post_meta($post->ID, 'price', true); ?></span>
                <span class="star-<?php echo get_post_meta($post->ID, 'rating', true); ?>rating"></span>
            </li>
        </ul>
     </section>

【问题讨论】:

  • 您的代码中没有endwhile...

标签: php html wordpress loops wordpress-theming


【解决方案1】:

endwhile; 添加到您的代码中。

<!--<?php while ( $myquery->have_posts() ) :  $myquery->the_post(); endwhile; ?>-->

或者做不同类型的while:

<!--<?php while ( $myquery->have_posts() ){  $myquery->the_post();} ?>-->

【讨论】:

  • 感谢循环目前正在运行
  • 我已经做到了:)
  • 我的意思是赞成它并检查它是否为绿色:)
猜你喜欢
  • 2012-01-02
  • 2011-11-11
  • 1970-01-01
  • 2014-06-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-06
  • 1970-01-01
相关资源
最近更新 更多