Created
December 4, 2019 21:53
-
-
Save designbuildtest/7e8b80b6e46eccfedfb562c1128eca74 to your computer and use it in GitHub Desktop.
Show featured posts on the front page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Show featured posts on the front page | |
* | |
* @link - https://wordpress.stackexchange.com/questions/202896/query-only-sticky-posts | |
*/ | |
function edward_featured_content_list() { | |
$featured = new WP_Query( | |
array( | |
'post_type' => 'page', | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'post_tag', | |
'field' => 'slug', | |
'terms' => 'featured', | |
), | |
), | |
'sort_column' => 'menu_order', // Important | |
'orderby' => 'menu_order', | |
'order' => 'ASC' | |
) | |
); | |
if ( $featured ) { ?> | |
<ol class="featured-list clear"> | |
<?php while ( $featured->have_posts() ) : $featured->the_post(); ?> | |
<?php get_template_part( 'template-parts/content/content', 'featured-list' ); ?> | |
<?php endwhile; ?> | |
</ol><?php | |
wp_reset_postdata(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment