WordPress.org

Support

Support » How-To and Troubleshooting » WP_Query and displaying pages

WP_Query and displaying pages

  • Hello

    I am having some difficulty displaying pages using WP_Query. My code is in functions.php as a part of a short code the following does not display the page when called.

    function entertainment_monthly_listings_function($atts){
    
    	$featured_winners_loop = new WP_Query( 'pagename=july-entertainment'); 
    
    	while ( $featured_winners_loop->have_posts() ) : $featured_winners_loop->the_post(); 
    
                    $return_string = the_content();
    
    					endwhile;
    					wp_reset_query();
    
       return $return_string;
    }

    but this does

    function entertainment_monthly_listings_function($atts){
    
    	$featured_winners_loop = new WP_Query( 'page_id=515'); 
    
    	while ( $featured_winners_loop->have_posts() ) : $featured_winners_loop->the_post(); 
    
                    $return_string = the_content();
    
    					endwhile;
    					wp_reset_query();
    
       return $return_string;
    }

    any help would be appreciated thanks

  • The topic ‘WP_Query and displaying pages’ is closed to new replies.