WordPress.org

Forums

WP_Query and displaying pages (1 post)

  1. superwhitepill
    Member
    Posted 1 year ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags