这个循环在服务器上不能正常工作?
This loop wouldn't work correctly on the server?
我已将此代码添加到 Wordpress 主题的前面-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 while ( $myquery->have_posts() ) : $myquery->the_post(); endwhile; ?>-->
或做不同类型的 while:
<!--<?php while ( $myquery->have_posts() ){ $myquery->the_post();} ?>-->
我已将此代码添加到 Wordpress 主题的前面-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 while ( $myquery->have_posts() ) : $myquery->the_post(); endwhile; ?>-->
或做不同类型的 while:
<!--<?php while ( $myquery->have_posts() ){ $myquery->the_post();} ?>-->