WordPress: Why shortcodes show a white page

I have this code to show news in block. but when include this code in function.php to call it in shortcode. It show me white page and not show me any error.

Sow where is error.??

Read More

For some reason, when I edit my functions.php, various pages turn white. For exmaple, with this code:

function box_news_eight( $atts ) {
$code = '<div class="cf"></div>
<div class="box-home box-news-seven nb-eight">
    <div class="box-inner">
        <div  class="box-wrap">';
            $query = new WP_Query( array( 'posts_per_page' => 1, 'cat' => 4, 'ignore_sticky_posts' => 1, 'no_found_rows' => true, 'cache_results' => false ) );
            if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
                if ( $i_cont == 0 ) { $post_class = ' ws-post-first'; } else { $post_class = ' ws-post-sec'; }
                if ( has_post_thumbnail() ) { $has_class =  ''; } else { $has_class =  ' no-thumb'; }
               $code .= ' <div class="post'.$post_class.','. $has_class.'" role="article" itemscope="" itemtype="http://schema.org/Article">';              
                    $post_sidebars = '';
                    if ( $post_sidebars == 'sideNo' ) {
                        if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : 
                            $code .= ' <div class="ws-thumbnail"><a href="'.get_the_permalink().'" rel="bookmark">
                                    .'get_the_post_thumbnail( 'bd-normal' ).'
                                </a></div>';
                            endif;
                        } else {
                                if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) :
                            $code .= '<div class="ws-thumbnail"><a href="'.get_the_permalink().'" rel="bookmark">';
                                        get_the_post_thumbnail( 'bd-large' );
                               $code .= '</a></div>';
                            endif; 
                        }
                    $code .= '<div class="ws-cap">
                        <div class="post-cats-bd">';
                            get_the_category( ' ' );
                        $code .= '</div>
                        <div class="ws-cap-inner">
                            <h3 itemprop="name" class="entry-title"><a itemprop="url" href="'.get_permalink( $post->ID ).'" rel="bookmark">'.get_the_title()'.</a></h3>
                            <div class="post-date-bd">'.
                                get_time().'
                            </div>
                        </div>
                    </div>
                </div>';
                 $i_cont++; endwhile; endif; wp_reset_postdata(); wp_reset_query();
            $query = new WP_Query( array( 'ignore_sticky_posts' => 1, 'offset'=>1, 'posts_per_page' => 4, 'cat' => 4, 'no_found_rows' => true, 'cache_results' => false ) );
            update_post_thumbnail_cache( $query );
            if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
                if ( $i_cont == 0 ) { $post_class = ' ws-post-first'; } else { $post_class = ' ws-post-sec'; }
                if ( has_post_thumbnail() ) { $has_class =  ''; } else { $has_class =  ' no-thumb'; }
                if( $count % 3 == 1 ) { echo '<div class="row">'; }
                    $code .= '<div class="post'.$post_class, $has_class.'" role="article" itemscope="" itemtype="http://schema.org/Article">
                        <div class="ws-meta">
                            <h3 itemprop="name" class="entry-title"><a itemprop="url" href="<'.get_permalink( $post->ID ).' rel="bookmark">'.the_title().'</a></h3>
                        </div>
                    </div>';
                      if( $count % 3 == 0 ) { echo "</div>n"; }
                      $count++;

                      $i_cont++; endwhile; endif; wp_reset_postdata(); wp_reset_query();
                  if ( $count % 3 != 1 ) echo "</div>";
        $code .= '</div>
    </div>
</div>';
return $code;
}
add_shortcode( 'box_news_eight', 'box_news_eight' );

Related posts

1 comment

  1. frist error

    .'get_the_post_thumbnail( 'bd-normal' )
    

    change to

    '.get_the_post_thumbnail( 'bd-normal' )
    

    second

    get_the_title()'.
    

    to

    get_the_title().'
    

    third

    $post_class, $has_class
    

    to

    $post_class.$has_class
    

Comments are closed.