WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] "The Loop" running "else" statement even though posts exist

[Resolved] "The Loop" running "else" statement even though posts exist

  • I am trying to create a loop for a custom post type called “portfolio”. I have published portfolio posts but for some reason my loop is running the “else” statement and echoing “WHERE MY POSTS?”. Can anyone tell me why?

    <?php
    		$args = array(
    			'post_type' => 'portfolio',
    			'tax_query' => array(
    				array(
    					'taxonomy' => 'portfolio_category',
    					'field' => 'slug',
    					'terms' => 'boardgames'
    				)
    			)
    		);
    		$portfolio = new WP_Query( $args );
    		if( $portfolio->have_posts() ) {
    			while( $portfolio->have_posts() ) {
    				$portfolio->the_post();
    				?>
    					<h1><?php the_title(); ?></h1>
    					<div class='content'>
    						<?php the_content(); ?>
    					</div>
    
    					<div class="four columns">
    				<a href="<?php the_permalink ?>">
    					<div class="img-wrp">
    				        <img class="scaleimg" src="<?php the_post_thumbnail ?>" />
    				        <div class="overlay-wrp">
    		    		        <i class="icon loupe overlay-content"></i>
    		    		        <div class="overlay"></div>
    				        </div>
    					</div>
    			    </a>
    				<p class="project-title"><?php the_title(); ?></p>
    				<p class="project-description"><?php the_excerpt(); ?></p>
    			</div><?php
    			}
    		}
    		else {
    			echo 'WHERE MY POSTS?';
    		}
    
    		?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] "The Loop" running "else" statement even though posts exist’ is closed to new replies.
Skip to toolbar