这个带有 3 个条件的 php if 语句有什么问题?
以下 if 语句有 3 个条件:
<?php if ( is_archive() ) : ?>
<?php $topic_tag_term = get_query_var( 'term' ); ?>
<?php // Display the top topics of current forum
$args = array(
'post_type' => 'topic',
'posts_per_page' => '3',
'topic-tag' => $topic_tag_term,
'r_sortby' => 'highest_rated',
'r_orderby' => 'desc',
'order' => 'DESC'
);
?>
<?php $term = $wp_query->queried_object; ?>
<p>The following are a list of topic tagged as <strong><?php echo $term->name ?></strong>.</p>
<?php if ( bbp_current_user_can_access_create_topic_form() ) : ?>
<a id="new-entry" href="<?php echo home_url( '/' ); ?>/create-topic">Start a new topic</a>
<?php endif; ?>
<?php if ( is_page_template() ) : ?>
<?php // Display the top topics of current forum
$args = array(
'post_type' => 'topic',
'posts_per_page' => '3',
'r_sortby' => 'highest_rated',
'r_orderby' => 'desc',
'order' => 'DESC',
'meta_key' => '_bbp_reply_count',
'meta_value' => '1',
'meta_compare' => '<'
);
?>
<?php else : ?>
<?php // Display the top topics of current forum
$args = array(
'post_type' => 'topic',
'posts_per_page' => '3',
'post_parent' => $post->ID,
'r_sortby' => 'highest_rated',
'r_orderby' => 'desc',
'order' => 'DESC'
);
?>
<?php endif; ?>
由于某种原因,此代码破坏了我的页面。
这有什么问题吗?
The following if statement has 3 conditions:
<?php if ( is_archive() ) : ?>
<?php $topic_tag_term = get_query_var( 'term' ); ?>
<?php // Display the top topics of current forum
$args = array(
'post_type' => 'topic',
'posts_per_page' => '3',
'topic-tag' => $topic_tag_term,
'r_sortby' => 'highest_rated',
'r_orderby' => 'desc',
'order' => 'DESC'
);
?>
<?php $term = $wp_query->queried_object; ?>
<p>The following are a list of topic tagged as <strong><?php echo $term->name ?></strong>.</p>
<?php if ( bbp_current_user_can_access_create_topic_form() ) : ?>
<a id="new-entry" href="<?php echo home_url( '/' ); ?>/create-topic">Start a new topic</a>
<?php endif; ?>
<?php if ( is_page_template() ) : ?>
<?php // Display the top topics of current forum
$args = array(
'post_type' => 'topic',
'posts_per_page' => '3',
'r_sortby' => 'highest_rated',
'r_orderby' => 'desc',
'order' => 'DESC',
'meta_key' => '_bbp_reply_count',
'meta_value' => '1',
'meta_compare' => '<'
);
?>
<?php else : ?>
<?php // Display the top topics of current forum
$args = array(
'post_type' => 'topic',
'posts_per_page' => '3',
'post_parent' => $post->ID,
'r_sortby' => 'highest_rated',
'r_orderby' => 'desc',
'order' => 'DESC'
);
?>
<?php endif; ?>
For some reason this code is breaking my page.
What is wrong with it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
至少应该是
这是我能看到的错误。
should be
at least this is the error I can see.
if (testcase)
后面的冒号不应该出现。我认为您对的使用感到困惑?
检查手册:这里
无意冒犯,但是每一行上的所有
都只是废话。
The colons after your
if (testcase)
should not be there. I think your confusing the use of?
Check the manual: here
No offence but all those
<?php ?>
on every line are just nonsense.该行末尾没有分号。
This line has no semi colon at the end.