php - 这个循环在服务器上不能正常工作?
问题描述
我已将此代码添加到 Wordpress 主题的 front-page.php 中,并为相关帖子添加了特色图片,但结果是以下错误消息: Parse error: syntax error, unexpected end of file in C:\xampp\ htdocs\wordpress\wp-content\themes\Resto 2\front-page.php on line 89 您的网站出现严重错误。这是我要使用的循环
<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 while ( $myquery->have_posts() ) : $myquery->the_post(); endwhile; ?>-->
或做不同类型的while:
<!--<?php while ( $myquery->have_posts() ){ $myquery->the_post();} ?>-->
推荐阅读
- python - 在 VS Code 中使用 docx 模块运行 Python Azure 函数时出现“异常:找不到包”
- haskell - 为什么“约束技巧”在这个手动定义的 HasField 实例中不起作用?
- list - FTP 的 STAT [file] 命令 (LIST [file]) 是否保证当前锁定文件的正确状态?
- angular - 无法使用 Angular Universal (SSR) 呈现内容内容
- fabricjs - 在 FabricJS 中,我如何阻止对象在选择时跳到“顶部”
- python - Windows 首次安装时是否带有 Visual C++ 编译器,是否需要编译 f2py 模块?
- node.js - gmail api auth 问题 - 无法从所选电子邮件中获取附件
- java - 找不到 com.github.rey5137:material:1.3.0
- javascript - Schedule a task to run as soon as browser repaint
- sql - How can i make a GROUP BY with a variable CASE