开发者

What's wrong with this php if-statement with 3 conditions?

The following if statemen开发者_JAVA百科t 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?


<?php if ( is_page_template() ) : ?>

should be

<?php elseif ( is_page_template() ) : ?>

at least this is the error I can see.


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.

<strong><?php echo $term->name ?></strong>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜