{"id":13187583,"date":"2020-07-29T20:08:41","date_gmt":"2020-07-29T20:08:41","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/wp_query-not-showing-featured-post\/"},"modified":"2020-07-29T20:08:41","modified_gmt":"2020-07-29T20:08:41","slug":"wp_query-not-showing-featured-post","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/wp_query-not-showing-featured-post\/","title":{"rendered":"Wp_Query not showing featured post"},"content":{"rendered":"<p>I am currently working through a wordpress course and I am building the homepage of the wordpress website and have ran into an issue. I am trying to use the WP Query class to create a featured post however, the post is not being displayed. Here&#8217;s my code.<\/p>\n<pre><code>\n&lt;section class=&quot;middle-area&quot;&gt;\n            &lt;div class=&quot;container&quot;&gt;\n                &lt;div class=&quot;row&quot;&gt;\n                    &lt;aside class=&quot;sidebar col-md-3 h-100&quot;&gt;\n\n                        &lt;?php \n                        \n                        \/\/ Require a file called sidebar-home.php\n                        get_sidebar( &#039;home&#039; ); \n\n                        ?&gt;\n                            \n                    &lt;\/aside&gt;\n                    &lt;div class=&quot;news col-md-9&quot;&gt;\n                    &lt;div class=&quot;row&quot;&gt;\n                        &lt;div class=&quot;container&quot;&gt;\n                            &lt;?php \n\n                            $featured = new WP_Query( &#039;post_type=post&amp;posts_per_page=1&amp;cat=4,11&#039; );\n\n                            if( $featured-&gt;have_posts() ):\n                                while( $featured-&gt;have_posts() ): $featured-&gt;the_post();\n                            ?&gt;\n\n                            &lt;div class=&quot;col-12&quot;&gt;\n                                &lt;?php get_template_part( &#039;template-parts\/content&#039;, &#039;featured&#039; ); ?&gt;\n                            &lt;\/div&gt;\n\n                            &lt;?php\n                                endwhile;\n                                wp_reset_postdata();\n                            endif;\n\n                            ?&gt;\n                        &lt;\/div&gt;\n                    &lt;\/div&gt;\n\n                    &lt;\/div&gt;                          \n                &lt;\/div&gt;\n            &lt;\/div&gt;\n        &lt;\/section&gt;\n<\/code><\/pre>\n<p>The content-featured file<\/p>\n<pre><code>\n&lt;article &lt;?php post_class( array( &#039;class&#039; =&gt; &#039;featured&#039; ) ); ?&gt;&gt;\n&lt;h2&gt;&lt;?php the_title(); ?&gt;&lt;\/h2&gt;\n&lt;div class=&quot;thumbnail&quot;&gt;\n    &lt;?php the_post_thumbnail( &#039;large&#039;, array( &#039;class&#039; =&gt; &#039;img-fluid&#039; ) ); ?&gt;\n&lt;\/div&gt;\n\n&lt;div class=&quot;meta-info&quot;&gt;\n    &lt;p&gt;\n        by &lt;span&gt;&lt;?php the_author_posts_link(); ?&gt;&lt;\/span&gt; \n        Categories: &lt;span&gt;&lt;?php the_category( &#039; &#039; ); ?&gt;&lt;\/span&gt;\n        &lt;?php the_tags( &#039; Tags: &lt;span&gt;&#039;, &#039;, &#039;, &#039;&lt;\/span&gt;&#039; ); ?&gt;\n    &lt;\/p&gt;\n    &lt;p&gt;&lt;span&gt;&lt;?php echo get_the_date(); ?&gt;&lt;\/p&gt;      \n&lt;\/div&gt;\n&lt;p&gt;&lt;?php the_excerpt(); ?&gt;&lt;\/p&gt;\n<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-13187583","topic","type-topic","status-publish","hentry","topic-tag-wordpress-theme-development"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/13187583","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/13187583\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=13187583"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}