Contributors: billerickson
Requires at least: 4.1
Tested up to: 4.9
Stable tag: 1.0.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
BE Featured Areas adds a checkbox to the Edit Post screen to mark the current post as featured. It uses a hidden taxonomy to store this data because tax queries are more performant than meta queries.
By default it has a single "Featured Post" checkbox, but you can use the filters to add additional featured areas.
Default option | Customized with different featured areas |
You could create your own metabox using ACF, storing the data as post meta. But if you have lots of posts (and post metadata), you can run into performance issues doing the meta query. Taxonomy queries are more scalable and a better fit for this use case.
You could register your own taxonomy, but you don't want to expose the full backend UI that allows content editors to add, remove, and edit taxonomy terms.
This plugin lets the theme define the featured areas (taxonomy terms) since they correspond with areas within that theme.
To query for posts with "Featured Post" checked (first screenshot):
$loop = new WP_Query( array(
'tax_query' => array(
array(
'taxonomy' => 'featured_area',
'field' => 'slug',
'terms' => 'featured',
)
)
) );
You can customize it with the following filters:
be_featured_areas
- Modify which featured areas are available (example)be_featured_areas_post_types
- Which post types can be featured. Default isarray( 'post' )
be_featured_areas_taxonomy
- Taxonomy used for featured areas. Default isfeatured_area
be_featured_areas_register_taxonomy
- Whether to create the taxonomy. You can disable registration if the taxonomy is registered elsewhere (example)