Shortcode leads to white screen [closed]

As I already stated in comments, your code is a complete mess and very hard to read and to debug. This is most probably why you are having a hard time to sort your issues.

Apart from a few syntax errors, you had a couple of bugs in your code like undefined variables (like your counters, you should define a counter before using it), trying to output an array instead of string. Also, please stop the crap where check if a core function exists. It is totally a waste of time.

You should use one syntax, and do not use multiple different syntaxes. You are using the following

if( 'something' ) {
    if( 'something else' ) :
        // Do something
    endif;
}

Don’t do that. It is confusing and a nightmare to debug as code editors in general do not support the : and endif syntax. Stick with curly brackets, they are easy to debug as all code editors support them. You should be using something like

if( 'something' ) {
    if( 'something else' ) {
        // Do something
    }
}

You should work on your indentation. This is very important is your code’s readability. Don’t cram a lot of code like conditional statements in to one line. It is really hard to read and to debug should it fail

Instead of doing the following which is bad coding

if ( has_post_thumbnail() ) { $has_class=""; } else { $has_class=" no-thumb"; }

split the code up into multiple lines and indent it correctly. Your code should look something like this

if ( has_post_thumbnail() ) { 
    $has_class=""; 
} else { 
    $has_class=" no-thumb"; 
}

You can see that this is easier to read and to debug

get_the_category() returns an array, you are trying to output the complete array of categories as a string. This will just lead to the word Array being output to screen

If you want to display a category name, you can do something like this (this will display the category name of the first category)

$category = get_the_category();
var_dump( $category[0]->name );

If you are passing multiple parameters to WP_Query, don’t pass it as one looooonnnnnnggggg line. Break it up into multiple lines which is easier to read

Instead of this

$query = new WP_Query( array( 'posts_per_page' => 1, 'cat' => 4, 'ignore_sticky_posts' => 1, 'no_found_rows' => true, 'cache_results' => false ) );

do the following which is easier to read

$args = array( 
    'posts_per_page'      => 1, 
    'cat'                 => 4, 
    'ignore_sticky_posts' => 1, 
    'no_found_rows'       => true, 
    'cache_results'       => false 
);
$query = new WP_Query( $args );

I do not know why you need to run 2 queries here and if it is really necessary, but in any case, I have not touched that as I don’t know what your intention is with this. Please compare my code with yours and see how my code compares to yours.

Here is your code cleaned up

add_shortcode( 'box_news_eight', 'box_news_eight' );
function box_news_eight() 
{
    $code="<div class="cf"></div>
    <div class="box-home box-news-seven nb-eight">
        <div class="box-inner">
            <div  class="box-wrap">";

                $args = array( 
                    'posts_per_page'      => 1, 
                    'cat'                 => 4, 
                    'ignore_sticky_posts' => 1, 
                    'no_found_rows'       => true, 
                    'cache_results'       => false 
                );
                $query = new WP_Query( $args );

                if ( $query->have_posts() ) { 
                    // Setup your counter
                    $i_cont = 0;

                    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 ( has_post_thumbnail() ) { 
                                $code .= '<div class="ws-thumbnail">
                                            <a href="'.get_the_permalink().'" rel="bookmark">'
                                                . get_the_post_thumbnail( 'bd-normal' ) .
                                            '</a>
                                        </div>';
                            }

                        } else {

                            if ( has_post_thumbnail() ) {
                                $code .= '<div class="ws-thumbnail">
                                            <a href="'.get_the_permalink().'" rel="bookmark">'
                                                . get_the_post_thumbnail( 'bd-large' ) .
                                            '</a>
                                        </div>';
                            } 

                        }
                        $category = get_the_category();
                        $code .= '<div class="ws-cap">
                                    <div class="post-cats-bd">'
                                        . $category[0]->name .
                                    '</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_the_time() .
                                        '</div>
                                    </div>
                                </div>
                            </div>';

                        $i_cont++; 
                    }
                    wp_reset_postdata();
                }

                $args_2 = array( 
                    'ignore_sticky_posts' => 1, 
                    'offset'              => 1, 
                    'posts_per_page'      => 4, 
                    'cat'                 => 4, 
                    'no_found_rows'       => true, 
                    'cache_results'       => false 
                );
                $query_2 = new WP_Query( $args_2 );
                update_post_thumbnail_cache( $query );

                if ( $query_2->have_posts() ) { 
                    $i_cont_2 = 0;
                    $count = 0;

                    while ( $query_2->have_posts() ) { 

                        $query_2->the_post();
                        if ( $i_cont_2 == 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 ) { 
                            $code .= '<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 ) { 
                            $code .= "</div>\n"; 
                        }

                        if ( $count % 3 != 1 ) { 
                            $code .= "</div>";
                        }

                        $count++;
                        $i_cont_2++; 
                    }
                    wp_reset_postdata(); 
                }

            $code .= '</div>
        </div>
    </div>';

    return $code;
}

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)