解析错误:语法错误,第12行意外的'else'(T_ELSE)archive.php

时间:2017-04-13 23:20:20

标签: wordpress-theming

同事请帮我修复这段代码我不是程序员。

  

解析错误:第12行的blog / public_html / wp-content / themes / munding-lite / archive.php中的语法错误,意外的'else'(T_ELSE)

<!DOCTYPE html>
<!--[if lt IE 7 ]><html class="ie ie6" <?php language_attributes(); ?>> <![endif]-->
<!--[if IE 7 ]><html class="ie ie7" <?php language_attributes(); ?>> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8" <?php language_attributes(); ?>> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--><html <?php language_attributes(); ?> > <!--<![endif]-->

<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<!--[if ie]><meta http-equiv='X-UA-Compatible' content="IE=edge,IE=9,IE=8,chrome=1" /><![endif]-->
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

<?php wp_head(); ?>

</head>

<body <?php body_class() ;?>>

<div id="preloader">
    <div id="status">&nbsp;</div>
</div>

<?php
$logo_id      = get_theme_mod( 'custom_logo' );
$logo_image   = wp_get_attachment_image_src( $logo_id, 'full' );
?>

<div class="container">

    <header id="header" class="header col-md-10 col-md-push-1 clearfix">
        <a id="mobile-menu" class="pull-left"><i class="icon icon-content-43"></i></a>

        <div class="logo pull-left">
            <?php if ( ! empty( $logo_image ) ) { ?>
            <div class="logo-image">
                <?php echo '<a href="' . esc_url( home_url() ) . '"><img src="' . esc_url( $logo_image[0] ) . '" /></a>'; ?>
            </div>
            <?php }
            else { ?>
            <h1 class="site-title">
                <a href="<?php echo esc_url( home_url() ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>" class="header-logo"><?php echo esc_html( get_bloginfo( 'name' ) ); ?></a>
            </h1>
            <?php } ?>
        </div><!-- logo -->
         <nav id="mainmenu" class="menu pull-right clearfix">
            <?php munding_lite_top_nav_menu(); ?>
        </nav> 

    </header>

</div>

<div id="main" class="site-main clearfix">
  

解析错误:第12行的blog / public_html / wp-content / themes / munding-lite / archive.php中的语法错误,意外的'else'(T_ELSE)

<?php get_header(); ?>

        <div id="content-wrapper" class="wrapper">

            <?php while ( have_posts() ) : the_post(); 


                    get_template_part( 'inc/format/loop', get_post_format() );

                endwhile; ?>

            <?php else : ?>
            <?php get_template_part( 'inc/format/loop', 'no-result' ); ?>

            <?php endif; ?>

        </div><!-- wrapper -->
        <div class="container">
        <div class="pagina col-md-10 col-md-push-1">
            <?php munding_lite_content_nav( 'nav-below' ); ?>
        </div>
        </div>


<?php get_footer(); ?>

1 个答案:

答案 0 :(得分:0)

你错过了if(have_post()):在while(have_post())之上:the_post();

尝试这对你有用。

    <div id="content-wrapper" class="wrapper">

        <?php if(have_posts()):
                while ( have_posts() ) : the_post(); 


                get_template_part( 'inc/format/loop', get_post_format() );

            endwhile; ?>

        <?php else : ?>
        <?php get_template_part( 'inc/format/loop', 'no-result' ); ?>

        <?php endif; ?>

    </div><!-- wrapper -->
    <div class="container">
    <div class="pagina col-md-10 col-md-push-1">
        <?php munding_lite_content_nav( 'nav-below' ); ?>
    </div>
    </div>