{"id":21818,"date":"2013-01-31T19:44:01","date_gmt":"2013-01-31T19:44:01","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/featured-item-metabox\/"},"modified":"2020-02-17T23:38:43","modified_gmt":"2020-02-17T23:38:43","slug":"featured-item-metabox","status":"publish","type":"plugin","link":"https:\/\/kn.wordpress.org\/plugins\/featured-item-metabox\/","author":5999535,"comment_status":"closed","ping_status":"closed","template":"","meta":{"version":"1.3.2","stable_tag":"1.4.0","tested":"5.3.21","requires":"3.8","requires_php":"","requires_plugins":"","header_name":"Featured Item Metabox","header_author":"Kathy Darling","header_description":"","assets_banners_color":"","last_updated":"2020-02-17 23:38:43","external_support_url":"","external_repository_url":"","donate_link":"https:\/\/www.paypal.com\/fundraiser\/112574644767835624\/charity\/1451316","header_plugin_uri":"http:\/\/wordpress.org\/extend\/plugins\/featured-item-metabox\/","header_author_uri":"http:\/\/www.kathyisawesome.com","rating":3,"author_block_rating":0,"active_installs":90,"downloads":4320,"num_ratings":2,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","changelog"],"tags":[],"upgrade_notice":[],"ratings":{"1":"1","2":0,"3":0,"4":0,"5":"1"},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0","1.0.1","1.1","1.1.2","1.1.4","1.2","1.2.1","1.2.3","1.2.4","1.3.0","1.3.2","1.4.0"],"block_files":[],"assets_screenshots":[],"screenshots":{"1":"The plugin settings","2":"Posts overview. Featured status can be changed via quickedit, or by simply clicking on the star icon.  Dark stars are featured whereas hollow stars are not.","3":"The metabox when editing an individual post"}},"plugin_section":[],"plugin_tags":[838,2205],"plugin_category":[],"plugin_contributors":[77657],"plugin_business_model":[],"class_list":["post-21818","plugin","type-plugin","status-publish","hentry","plugin_tags-featured","plugin_tags-metabox","plugin_contributors-helgatheviking","plugin_committers-helgatheviking"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/featured-item-metabox.svg","icon_2x":false,"generated":true},"screenshots":[],"raw_content":"<!--section=description-->\n<p>I found I constantly needed a way for clients to mark a post as something they wanted to feature and I've never found sticky posts particularly inuitive and the UI is pretty hidden for new users.  The simplest solution was a checkbox in prominently located metabox.<\/p>\n\n<p>Please note that this plugin, by itself, will not change how your posts are displayed.  It just gives the UI to users and a meta key to theme developers to query for.<\/p>\n\n<h4>Usage<\/h4>\n\n<p>This plugin simply adds a <code>_featured<\/code> meta key to every post with a value of <code>yes<\/code> for featured items and <code>no<\/code> for everything else.  Actual display of the featured items is entirely up to the theme developer, but an example ( place in your template where you'd like to display a list of featured \"Portfolios\") might be as follows:<\/p>\n\n<pre><code>\/\/ params for our query\n$args = array(\n    'post_type' =&gt; 'portfolio',\n   'posts_per_page'  =&gt; 5,\n   'meta_key'        =&gt; '_featured',\n   'meta_value'      =&gt; 'yes'\n);\n\n\/\/ The Query\n$featured_portfolios = new WP_Query( $args );\n\n\/\/ The Loop\nif ( $featured_portfolios ) :\n\n    echo '&lt;ul class=\"featured\"&gt;';\n\n    while ( $featured_portfolios-&gt;have_posts() ) :\n        $featured_portfolios-&gt;the_post();\n        echo '&lt;li&gt;' . get_the_title() . '&lt;\/li&gt;';\n    endwhile;\n\n    echo '&lt;\/ul&gt;';\n\nelse :\n\n    echo 'No featured portfolios found.';\n\nendif;\n\n\/* Restore original Post Data\n * NB: Because we are using new WP_Query we aren't stomping on the\n * original $wp_query and it does not need to be reset.\n*\/\nwp_reset_postdata();\n<\/code><\/pre>\n\n<p>Multiple queries per page load can slow down your site so it is worthwhile to take advantage of the <a href=\"http:\/\/codex.wordpress.org\/Transients_API\">Transients API<\/a>, so an alternate usage would be:<\/p>\n\n<pre><code>\/\/ Get any existing copy of our transient data\nif ( false === ( $featured_portfolios = get_transient( 'featured_portfolios' ) ) ) {\n    \/\/ It wasn't there, so regenerate the data and save the transient\n\n   \/\/ params for our query\n    $args = array(\n        'post_type' =&gt; 'portfolio',\n       'posts_per_page'  =&gt; 5,\n       'meta_key'        =&gt; '_featured',\n       'meta_value'      =&gt; 'yes'\n    );\n\n    \/\/ The Query\n    $featured_portfolios = new WP_Query( $args );\n\n    \/\/ store the transient\n    set_transient( 'featured_portfolios', $featured_portfolios );\n\n}\n\n\/\/ Use the data like you would have normally...\n\n\/\/ The Loop\nif ( $featured_portfolios ) :\n\n    echo '&lt;ul class=\"featured\"&gt;';\n\n    while ( $featured_portfolios-&gt;have_posts() ) :\n        $featured_portfolios-&gt;the_post();\n        echo '&lt;li&gt;' . get_the_title() . '&lt;\/li&gt;';\n    endwhile;\n\n    echo '&lt;\/ul&gt;';\n\nelse :\n\n    echo 'No featured portfolios found.';\n\nendif;\n\n\/* Restore original Post Data\n * NB: Because we are using new WP_Query we aren't stomping on the\n * original $wp_query and it does not need to be reset.\n*\/\nwp_reset_postdata();\n<\/code><\/pre>\n\n<p>Then to ensure that your featured posts list is updated, add a function to your theme's functions.php to delete the transient when a portfolio (in this example) post type is saved.<\/p>\n\n<pre><code>\/\/ Create a function to delete our transient when a portfolio post is saved\nfunction save_post_delete_featured_transient( $post_id ) {\n   if ( 'portfolio' == get_post_type( $post_id ) )\n    delete_transient( 'featured_portfolios' );\n}\n\/\/ Add the function to the save_post hook so it runs when posts are saved\nadd_action( 'save_post', 'save_post_delete_featured_transient' );\n<\/code><\/pre>\n\n<p>Simple queries should only need the <code>meta_key<\/code> and <code>meta_value<\/code> parameters, but if you need something more advanced then you might want to read about how to use the more <a href=\"http:\/\/scribu.net\/wordpress\/advanced-metadata-queries.html\">complex Meta Query parameters<\/a>.<\/p>\n\n<h4>Support<\/h4>\n\n<p>Support is handled in the <a href=\"http:\/\/wordpress.org\/support\/plugin\/featured-item-metabox\">WordPress forums<\/a>.  Please note that support is limited and does not cover any custom implementation of the plugin.<\/p>\n\n<p>Please report any bugs, errors, warnings, code problems at <a href=\"https:\/\/github.com\/helgatheviking\/Featured-Item-Metabox\/issues\">Github<\/a><\/p>\n\n<!--section=installation-->\n<ol>\n<li>Upload the <code>plugin<\/code> folder to the <code>\/wp-content\/plugins\/<\/code> directory<\/li>\n<li>Activate the plugin through the 'Plugins' menu in WordPress<\/li>\n<li>Go to the plugin's settings and select which post types for which you'd like to show the featured metabox<\/li>\n<\/ol>\n\n<!--section=changelog-->\n<h4>1.4.0<\/h4>\n\n<ul>\n<li>Gutenberg compatibility<\/li>\n<\/ul>\n\n<h4>1.3.2<\/h4>\n\n<ul>\n<li>fixes bug where toggle script wasn't loading if \"remove all\" plugin option was checked<\/li>\n<\/ul>\n\n<h4>1.3.1<\/h4>\n\n<ul>\n<li>fixes problem of quick edit not adjusting to toggle<\/li>\n<\/ul>\n\n<h4>1.3.0<\/h4>\n\n<ul>\n<li>testing against WP4.4<\/li>\n<li>on posts overview page, use ajax to toggle featured on\/off<\/li>\n<li>replace star images with dashicons<\/li>\n<\/ul>\n\n<h4>1.2.4<\/h4>\n\n<ul>\n<li>testing against WP4.3<\/li>\n<li>improved code formatting<\/li>\n<\/ul>\n\n<h4>1.2.3<\/h4>\n\n<ul>\n<li>add featured_items_metabox_label filter<\/li>\n<li>add featured_items_checkbox_label filter<\/li>\n<\/ul>\n\n<h4>1.2.2<\/h4>\n\n<ul>\n<li>make plugin work on media attachments<\/li>\n<\/ul>\n\n<h4>1.2.1<\/h4>\n\n<ul>\n<li>Fixing file rename<\/li>\n<\/ul>\n\n<h4>1.2<\/h4>\n\n<ul>\n<li>switching to singular instance of plugin, to prevent the need to use globals (global still there for backcompat)<\/li>\n<li>don't show private post types as possibilities in options <\/li>\n<li>update documentaion<\/li>\n<li>update docbloc<\/li>\n<\/ul>\n\n<h4>1.1.4<\/h4>\n\n<ul>\n<li>verify WP 3.8 compatibility<\/li>\n<\/ul>\n\n<h4>1.1.3<\/h4>\n\n<ul>\n<li>fix more warnings. props @pushka<\/li>\n<\/ul>\n\n<h4>1.1.2<\/h4>\n\n<ul>\n<li>php strict standards for static variables<\/li>\n<\/ul>\n\n<h4>1.1.1<\/h4>\n\n<ul>\n<li>update FAQ<\/li>\n<\/ul>\n\n<h4>1.1<\/h4>\n\n<ul>\n<li>fix whitescreen bug on ajax action for edit columns<\/li>\n<\/ul>\n\n<h4>1.0.1<\/h4>\n\n<ul>\n<li>fix markdown for changelog<\/li>\n<\/ul>\n\n<h4>1.0<\/h4>\n\n<ul>\n<li>Initial release.<\/li>\n<\/ul>","raw_excerpt":"Quickly add a metabox to any post type for marking a post as featured.  Toggle featured status even more quickly from the posts lists\/ quick edit scre &hellip;","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/kn.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/21818","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kn.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/kn.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/kn.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=21818"}],"author":[{"embeddable":true,"href":"https:\/\/kn.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/helgatheviking"}],"wp:attachment":[{"href":"https:\/\/kn.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=21818"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/kn.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=21818"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/kn.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=21818"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/kn.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=21818"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/kn.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=21818"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/kn.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=21818"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}