如何解决Parse错误:语法错误,意外':',期待';'

时间:2014-01-28 07:52:40

标签: php wordpress wordpress-theming

我使用了我的代码,但它的错误Parse错误:语法错误,第39行的意外T_IF shop \ wrapper-start.php 我的代码,可以帮助我吗?

<?php
switch( $template ) {
        case 'twentythirteen' :
            echo '<div id="primary" class="site-content"><div id="content" role="main" class="entry-content twentythirteen">';
            break;
        default :
            echo '<div class="content-container">';
            echo '<div class="bg-left">';
            echo the_post_thumbnail('full', array('class' => 'img-banner'));
            echo '</div>';
            echo '<div class="content-right">';
            echo '<div class="menu-wrapper">';               
            echo '<div class="menu-wrapper-inner">';    
            echo wp_nav_menu();
            echo '</div>';
            echo '</div>';
            echo '<div class="content-inner">';
            echo '<div class="container-inner">';       
            echo if (have_posts()) : while (have_posts()) : the_post();
            echo the_content();         
            echo endwhile else;
            echo '<p>Sorry, no posts matched your criteria.</p>';                   
            echo endif;              
            echo '</div>';      
            echo '</div>';      
            echo '</div>';      
            echo '<div class="sidebar">';       
            echo get_sidebar();         
            echo '</div>';  
            echo get_footer();      

            break;
    }

1 个答案:

答案 0 :(得分:0)

switch( $template ) {
    case 'twentythirteen' :
        echo '<div id="primary" class="site-content"><div id="content" role="main" class="entry-content twentythirteen">';
        break;
    default :
        echo '<div class="content-container">';
        echo '<div class="bg-left">';
        echo the_post_thumbnail('full', array('class' => 'img-banner'));
        echo '</div>';
        echo '<div class="content-right">';
        echo '<div class="menu-wrapper">';               
        echo '<div class="menu-wrapper-inner">';    
        echo wp_nav_menu();
        echo '</div>';
        echo '</div>';
        echo '<div class="content-inner">';
        echo '<div class="container-inner">';       
        if (have_posts()) : while (have_posts()) : the_post();
            echo the_content();         
         endwhile; 
         else:
            echo '<p>Sorry, no posts matched your criteria.</p>';                   
        endif;              
        echo '</div>';      
        echo '</div>';      
        echo '</div>';      
        echo '<div class="sidebar">';       
        echo get_sidebar();         
        echo '</div>';  
        echo get_footer();      

        break;
}

试试这段代码。错误是因为,你在if&amp;条件。你不需要回应条件。 希望这会有所帮助。