Why am I getting syntax error, unexpected 'endwhile' (T_ENDWHILE) on single.php

Here is the code for my Single.php in my theme folder. I am not sure what is wrong.<?phpget_header();$show_default_ti

Here is the code for my Single.php in my theme folder. I am not sure what is wrong.

<?php

get_header();

$show_default_title = get_post_meta( get_the_ID(), '_et_pb_show_title', true );

$is_page_builder_used = et_pb_is_pagebuilder_used( get_the_ID() );

?>

<div id="main-content">
    <?php
        if ( et_builder_is_product_tour_enabled() ):
            // load fullwidth page in Product Tour mode
            while ( have_posts() ): the_post(); ?>

                <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                    <div class="entry-content">
                    <?php
                        the_content();
                    ?>
                    </div> <!-- .entry-content -->

                </article> <!-- .et_pb_post -->

        <?php endwhile;
        else:
    ?>
    <div class="container">
        <div id="content-area" class="clearfix">
            <div id="left-area">
            <?php while ( have_posts() ) : the_post(); ?>
                <?php if (et_get_option('divi_integration_single_top') <> '' && et_get_option('divi_integrate_singletop_enable') == 'on') echo(et_get_option('divi_integration_single_top')); ?>
                <article id="post-<?php the_ID(); ?>" <?php post_class( 'et_pb_post' ); ?>>
                    <?php if ( ( 'off' !== $show_default_title && $is_page_builder_used ) || ! $is_page_builder_used ) { ?>
                        <div class="et_post_meta_wrapper">
                            <h1 class="entry-title"><?php the_title(); ?></h1>

                        <?php
                            if ( ! post_password_required() ) :

                                et_divi_post_meta();

                                $thumb = '';

                                $width = (int) apply_filters( 'et_pb_index_blog_image_width', 1080 );

                                $height = (int) apply_filters( 'et_pb_index_blog_image_height', 675 );
                                $classtext = 'et_featured_image';
                                $titletext = get_the_title();
                                $thumbnail = get_thumbnail( $width, $height, $classtext, $titletext, $titletext, false, 'Blogimage' );
                                $thumb = $thumbnail["thumb"];

                                $post_format = et_pb_post_format();

                                if ( 'video' === $post_format && false !== ( $first_video = et_get_first_video() ) ) {
                                    printf(
                                        '<div class="et_main_video_container">
                                            %1$s
                                        </div>',
                                        $first_video
                                    );
                                } else if ( ! in_array( $post_format, array( 'gallery', 'link', 'quote' ) ) && 'on' === et_get_option( 'divi_thumbnails', 'on' ) && '' !== $thumb ) {
                                    print_thumbnail( $thumb, $thumbnail["use_timthumb"], $titletext, $width, $height );
                                } else if ( 'gallery' === $post_format ) {
                                    et_pb_gallery_images();
                                }
                            ?>

                            <?php
                                $text_color_class = et_divi_get_post_text_color();

                                $inline_style = et_divi_get_post_bg_inline_style();

                                switch ( $post_format ) {
                                    case 'audio' :
                                        $audio_player = et_pb_get_audio_player();

                                        if ( $audio_player ) {
                                            printf(
                                                '<div class="et_audio_content%1$s"%2$s>
                                                    %3$s
                                                </div>',
                                                esc_attr( $text_color_class ),
                                                $inline_style,
                                                $audio_player
                                            );
                                        }

                                        break;
                                    case 'quote' :
                                        printf(
                                            '<div class="et_quote_content%2$s"%3$s>
                                                %1$s
                                            </div> <!-- .et_quote_content -->',
                                            et_get_blockquote_in_content(),
                                            esc_attr( $text_color_class ),
                                            $inline_style
                                        );

                                        break;
                                    case 'link' :
                                        printf(
                                            '<div class="et_link_content%3$s"%4$s>
                                                <a href="%1$s" class="et_link_main_url">%2$s</a>
                                            </div> <!-- .et_link_content -->',
                                            esc_url( et_get_link_url() ),
                                            esc_html( et_get_link_url() ),
                                            esc_attr( $text_color_class ),
                                            $inline_style
                                        );

                                        break;
                                }

                            endif;
                        ?>
                    </div> <!-- .et_post_meta_wrapper -->
                <?php  } ?>

                    <div class="entry-content">
                    <?php
                        do_action( 'et_before_content' );

                        the_content();

                        wp_link_pages( array( 'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'Divi' ), 'after' => '</div>' ) );
                    ?>
                    </div> <!-- .entry-content -->
                    <div class="et_post_meta_wrapper">
                    <?php
                    if ( et_get_option('divi_468_enable') == 'on' ){
                        echo '<div class="et-single-post-ad">';
                        if ( et_get_option('divi_468_adsense') <> '' ) echo( et_get_option('divi_468_adsense') );
                        else { ?>
                            <a href="<?php echo esc_url(et_get_option('divi_468_url')); ?>"><img src="<?php echo esc_attr(et_get_option('divi_468_image')); ?>" alt="468" class="foursixeight" /></a>
                <?php   }
                        echo '</div> <!-- .et-single-post-ad -->';
                    }
                ?>

                    <?php if (et_get_option('divi_integration_single_bottom') <> '' && et_get_option('divi_integrate_singlebottom_enable') == 'on') echo(et_get_option('divi_integration_single_bottom')); ?>

                    <?php
                        if ( ( comments_open() || get_comments_number() ) && 'on' == et_get_option( 'divi_show_postcomments', 'on' ) ) {
                            comments_template( '', true );
                        }
                    ?>
                    </div> <!-- .et_post_meta_wrapper -->

                     <?php $orig_post = $post;
global $post;
$categories = get_the_category($post->ID);
if ($categories) {
$category_ids = array();
foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;

$args=array(
'category__in' => $category_ids,
'post__not_in' => array($post->ID),
'posts_per_page'=> 3, // Number of related posts that will be shown.
'caller_get_posts'=>3
);

$my_query = new wp_query( $args );
if( $my_query->have_posts() ) {
echo '<div id="related_posts"><h3>Related Posts</h3><ul>';
while( $my_query->have_posts() ) {
$my_query->the_post();?>

<li><div class="relatedthumb"><a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_post_thumbnail(); ?></a></div>
<div class="relatedcontent">
<h3><a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
<p><?php $content = get_the_content(); echo mb_strimwidth($content, 0, 100, '...');?></p>
<span class="author"><?php the_author(); ?></span>
</div>
</li>
<?
}
echo '</ul><div class="clear"></div></div>';
}
}
$post = $orig_post;
wp_reset_query(); ?>


                </article> <!-- .et_pb_post -->

            <?php endwhile; ?>




            </div> <!-- #left-area -->

            <?php get_sidebar(); ?>
        </div> <!-- #content-area -->
    </div> <!-- .container -->
    <?php //endif; ?>
</div> <!-- #main-content -->

<?php //get_footer(); ?>

Here is the code for my Single.php in my theme folder. I am not sure what is wrong.

<?php

get_header();

$show_default_title = get_post_meta( get_the_ID(), '_et_pb_show_title', true );

$is_page_builder_used = et_pb_is_pagebuilder_used( get_the_ID() );

?>

<div id="main-content">
    <?php
        if ( et_builder_is_product_tour_enabled() ):
            // load fullwidth page in Product Tour mode
            while ( have_posts() ): the_post(); ?>

                <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                    <div class="entry-content">
                    <?php
                        the_content();
                    ?>
                    </div> <!-- .entry-content -->

                </article> <!-- .et_pb_post -->

        <?php endwhile;
        else:
    ?>
    <div class="container">
        <div id="content-area" class="clearfix">
            <div id="left-area">
            <?php while ( have_posts() ) : the_post(); ?>
                <?php if (et_get_option('divi_integration_single_top') <> '' && et_get_option('divi_integrate_singletop_enable') == 'on') echo(et_get_option('divi_integration_single_top')); ?>
                <article id="post-<?php the_ID(); ?>" <?php post_class( 'et_pb_post' ); ?>>
                    <?php if ( ( 'off' !== $show_default_title && $is_page_builder_used ) || ! $is_page_builder_used ) { ?>
                        <div class="et_post_meta_wrapper">
                            <h1 class="entry-title"><?php the_title(); ?></h1>

                        <?php
                            if ( ! post_password_required() ) :

                                et_divi_post_meta();

                                $thumb = '';

                                $width = (int) apply_filters( 'et_pb_index_blog_image_width', 1080 );

                                $height = (int) apply_filters( 'et_pb_index_blog_image_height', 675 );
                                $classtext = 'et_featured_image';
                                $titletext = get_the_title();
                                $thumbnail = get_thumbnail( $width, $height, $classtext, $titletext, $titletext, false, 'Blogimage' );
                                $thumb = $thumbnail["thumb"];

                                $post_format = et_pb_post_format();

                                if ( 'video' === $post_format && false !== ( $first_video = et_get_first_video() ) ) {
                                    printf(
                                        '<div class="et_main_video_container">
                                            %1$s
                                        </div>',
                                        $first_video
                                    );
                                } else if ( ! in_array( $post_format, array( 'gallery', 'link', 'quote' ) ) && 'on' === et_get_option( 'divi_thumbnails', 'on' ) && '' !== $thumb ) {
                                    print_thumbnail( $thumb, $thumbnail["use_timthumb"], $titletext, $width, $height );
                                } else if ( 'gallery' === $post_format ) {
                                    et_pb_gallery_images();
                                }
                            ?>

                            <?php
                                $text_color_class = et_divi_get_post_text_color();

                                $inline_style = et_divi_get_post_bg_inline_style();

                                switch ( $post_format ) {
                                    case 'audio' :
                                        $audio_player = et_pb_get_audio_player();

                                        if ( $audio_player ) {
                                            printf(
                                                '<div class="et_audio_content%1$s"%2$s>
                                                    %3$s
                                                </div>',
                                                esc_attr( $text_color_class ),
                                                $inline_style,
                                                $audio_player
                                            );
                                        }

                                        break;
                                    case 'quote' :
                                        printf(
                                            '<div class="et_quote_content%2$s"%3$s>
                                                %1$s
                                            </div> <!-- .et_quote_content -->',
                                            et_get_blockquote_in_content(),
                                            esc_attr( $text_color_class ),
                                            $inline_style
                                        );

                                        break;
                                    case 'link' :
                                        printf(
                                            '<div class="et_link_content%3$s"%4$s>
                                                <a href="%1$s" class="et_link_main_url">%2$s</a>
                                            </div> <!-- .et_link_content -->',
                                            esc_url( et_get_link_url() ),
                                            esc_html( et_get_link_url() ),
                                            esc_attr( $text_color_class ),
                                            $inline_style
                                        );

                                        break;
                                }

                            endif;
                        ?>
                    </div> <!-- .et_post_meta_wrapper -->
                <?php  } ?>

                    <div class="entry-content">
                    <?php
                        do_action( 'et_before_content' );

                        the_content();

                        wp_link_pages( array( 'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'Divi' ), 'after' => '</div>' ) );
                    ?>
                    </div> <!-- .entry-content -->
                    <div class="et_post_meta_wrapper">
                    <?php
                    if ( et_get_option('divi_468_enable') == 'on' ){
                        echo '<div class="et-single-post-ad">';
                        if ( et_get_option('divi_468_adsense') <> '' ) echo( et_get_option('divi_468_adsense') );
                        else { ?>
                            <a href="<?php echo esc_url(et_get_option('divi_468_url')); ?>"><img src="<?php echo esc_attr(et_get_option('divi_468_image')); ?>" alt="468" class="foursixeight" /></a>
                <?php   }
                        echo '</div> <!-- .et-single-post-ad -->';
                    }
                ?>

                    <?php if (et_get_option('divi_integration_single_bottom') <> '' && et_get_option('divi_integrate_singlebottom_enable') == 'on') echo(et_get_option('divi_integration_single_bottom')); ?>

                    <?php
                        if ( ( comments_open() || get_comments_number() ) && 'on' == et_get_option( 'divi_show_postcomments', 'on' ) ) {
                            comments_template( '', true );
                        }
                    ?>
                    </div> <!-- .et_post_meta_wrapper -->

                     <?php $orig_post = $post;
global $post;
$categories = get_the_category($post->ID);
if ($categories) {
$category_ids = array();
foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;

$args=array(
'category__in' => $category_ids,
'post__not_in' => array($post->ID),
'posts_per_page'=> 3, // Number of related posts that will be shown.
'caller_get_posts'=>3
);

$my_query = new wp_query( $args );
if( $my_query->have_posts() ) {
echo '<div id="related_posts"><h3>Related Posts</h3><ul>';
while( $my_query->have_posts() ) {
$my_query->the_post();?>

<li><div class="relatedthumb"><a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_post_thumbnail(); ?></a></div>
<div class="relatedcontent">
<h3><a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
<p><?php $content = get_the_content(); echo mb_strimwidth($content, 0, 100, '...');?></p>
<span class="author"><?php the_author(); ?></span>
</div>
</li>
<?
}
echo '</ul><div class="clear"></div></div>';
}
}
$post = $orig_post;
wp_reset_query(); ?>


                </article> <!-- .et_pb_post -->

            <?php endwhile; ?>




            </div> <!-- #left-area -->

            <?php get_sidebar(); ?>
        </div> <!-- #content-area -->
    </div> <!-- .container -->
    <?php //endif; ?>
</div> <!-- #main-content -->

<?php //get_footer(); ?>
Share Improve this question edited Aug 13, 2019 at 15:05 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Aug 13, 2019 at 13:46 Jason BrashearJason Brashear 1 2
  • Error: Parse error: syntax error, unexpected 'endwhile' (T_ENDWHILE) in /var/www/html/jon2/wp-content/themes/macroux/single.php on line 189 The site is experiencing technical difficulties. – Jason Brashear Commented Aug 13, 2019 at 13:46
  • You don't have any while statement open. Your last while on line 168 uses curly braces { } and closes on line 179, so when you get to line 189 the endwhile does nothing and confuses PHP. It may help if you work on indenting your code and also always use curly braces, so it's easier to tell where one statement begins and ends. Many editors will show you the paired curly brace when you select one (select the beginning, it will show you the end). – WebElaine Commented Aug 13, 2019 at 13:56
Add a comment  | 

1 Answer 1

Reset to default 0

I strongly suspect that you haven't ended your second while loop for <?php while ( have_posts() ) : the_post(); ?> being used on line 32

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745245946a4618411.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信