Widget Part not getting displayed in the front end

Although the widget Title is getting displayed, but the Post part(Generating through the loop) is not getting displayed. what mistake am I committing?

public function widget($args, $instance) {
        extract( $args );
        $title = apply_filters( 'widget_title', $instance['title'] );

    /* Display the markup before the widget. */
    echo $before_widget;
    if ( $title ) {
        echo $before_title . $title . $after_title;
    /* Create a custom query and get the most recent 6 projects. */
    $queryArgs = array(
        /* Do not get posts from the Uncategorized category. */
        'cat' => '-1',
        /* Order by date. */
        'orderby' => 'date',
        /* Show all posts. */
        'posts_per_page' => '2'
    $query = new WP_Query( $queryArgs );
    if ( $query->have_posts() ) : ?>
        <ul class="bullet-un">
        <?php while ( $query->have_posts() ) : $query->the_post(); ?>
            <li class="snippet-box vertical">
                    <!-- <img src="http://heightandweights.com/wp-content/uploads/2014/10/Beautiful-Lindsey-Vonn.jpg" alt="" class="hundred"> -->
                    <?php the_post_thumbnail( 'large', array( 'class' => 'img-responsive' ) ); ?>
                    <div class="snippet-text">
                        <h3><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"></a></h3>
                        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>

        <?php endwhile; ?>
    <?php endif;
    /* Display the markup after the widget. */
    echo $after_widget;

My Problem is solved actually the code is correct, but all post were in uncategorized section therefore they were not showing. I do not have the option to delete this post.

1 Like

Thanks for posting the solution.

No need to delete your post. If you can make that mistake, then other folk may make the same mistake, and your thread may be of help to someone else.

1 Like

Ok sir. Thanks!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.