syntax error, unexpected 'endif' (T_ENDIF)

2019-03-06 17:16发布

问题:

I've been working on this code error for my worpress site offline.

Parse error: syntax error, unexpected 'endif' (T_ENDIF) in /homez.541/photoher/marie/wp-content/themes/hemingway/functions.php on line 288

Line code error line 288: <p class="comment-awaiting-moderation"><?php _e( 'Awaiting moderation', 'hemingway' ); ?></p>

Here is the whole code for the error:

    <li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">

        <?php __( 'Pingback:', 'hemingway' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( '(Edit)', 'hemingway' ), '<span class="edit-link">', '</span>' ); ?>

    </li>
    <?php
            break;
        default :
        global $post;
    ?>
    <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">

        <div id="comment-<?php comment_ID(); ?>" class="comment">

            <div class="comment-meta comment-author vcard">

                <?php echo get_avatar( $comment, 120 ); ?>

                <div class="comment-meta-content">

                    <?php printf( '<cite class="fn">%1$s %2$s</cite>',
                        get_comment_author_link(),
                        ( $comment->user_id === $post->post_author ) ? '<span class="post-author"> ' . __( '(Post author)', 'hemingway' ) . '</span>' : ''
                    ); ?>

                    <p><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ) ?>"><?php echo get_comment_date() . ' at ' . get_comment_time() ?></a></p>

                </div> <!-- /comment-meta-content -->

            </div> <!-- /comment-meta -->

            <div class="comment-content post-content">

                <?php if ( '0' == $comment->comment_approved ) : ?>

                    <p class="comment-awaiting-moderation"><?php _e( 'Awaiting moderation', 'hemingway' ); ?></p>

                <?php endif; ?>

                <?php comment_text(); ?>

                <div class="comment-actions">

                    <?php edit_comment_link( __( 'Edit', 'hemingway' ), '', '' ); ?>

                    <?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply', 'hemingway' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>

                    <div class="clear"></div>

                </div> <!-- /comment-actions -->

            </div><!-- /comment-content -->

        </div><!-- /comment-## -->
    <?php
        break;
    endswitch;
}
endif;

Please help me.

回答1:

You shouldn't have a } endif;.

Use if (...) {} or if (...):/endif;, but don't use both.



标签: php wordpress