Support » Fixing WordPress » WP_Query not doing anything.

  • I need help figuring out what is going on with my query, here. The page continues to load fine, and nothing seems to be breaking… but the page renders as if the query wasn’t there. I’ve checked to make sure my custom post type name is correct. I’ve been working on this the last couple of hours, and I just can’t seem to figure out what’s wrong w/ this. If anyone can take a look at this and see if they might see something I am missing, I would be really appreciate any input towards fixing this or optimizing it.

    <?php
    // The Query
    
    $args = array( 'post_type' => 'calendars' , 'posts_per_page' => 10 );
    $get_calbanners = new WP_Query( $args );
    
    //The 'new' loop
    if( $get_calbanners->have_posts() ) {
    	while( $get_calbanners->have_posts() ){
    		$get_calbanners->the_post();
    
    		function cbcb_ftrimg_insert() {
    			if( has_post_thumbnail() ) {
    				the_post_thumbnail('calbanner');
    			}
    			else {
    				the_title();
    			}
    		}
    
    		echo '<div class="bannerspan"><a href="' . get_permalink() . '" title="'. the_title_attribute() .'">'. cbcb_ftrimg_insert() .'</a></div>';
    	}
    }
    else { ?>
    <p><?php _e( 'Sorry, No posts matched your criteria.' ); ?></p><?php
    }
    wp_reset_postdata();

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WP_Query not doing anything.’ is closed to new replies.