Linux 软件免费装

Featured Item Metabox

开发者 helgatheviking
更新时间 2020年2月18日 07:40
捐献地址: 去捐款
PHP版本: 3.8 及以上
WordPress版本: 5.3.2
版权: GPLv3 or later
版权网址: 版权信息

标签

featured metabox

下载

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

详情介绍:

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. 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. 用法 This plugin simply adds a _featured meta key to every post with a value of yes for featured items and no 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: ` // params for our query $args = array( 'post_type' => 'portfolio', 'posts_per_page' => 5, 'meta_key' => '_featured', 'meta_value' => 'yes' ); // The Query $featured_portfolios = new WP_Query( $args ); // The Loop if ( $featured_portfolios ) : echo ''; else : echo 'No featured portfolios found.'; endif; /* Restore original Post Data ` // Get any existing copy of our transient data if ( false === ( $featured_portfolios = get_transient( 'featured_portfolios' ) ) ) { // It wasn't there, so regenerate the data and save the transient // params for our query $args = array( 'post_type' => 'portfolio', 'posts_per_page' => 5, 'meta_key' => '_featured', 'meta_value' => 'yes' ); // The Query $featured_portfolios = new WP_Query( $args ); // store the transient set_transient( 'featured_portfolios', $featured_portfolios ); } // Use the data like you would have normally... // The Loop if ( $featured_portfolios ) : echo ''; else : echo 'No featured portfolios found.'; endif; /* Restore original Post Data // Create a function to delete our transient when a portfolio post is saved function save_post_delete_featured_transient( $post_id ) { if ( 'portfolio' == get_post_type( $post_id ) ) delete_transient( 'featured_portfolios' ); } // Add the function to the save_post hook so it runs when posts are saved add_action( 'save_post', 'save_post_delete_featured_transient' ); Simple queries should only need the meta_key and meta_value parameters, but if you need something more advanced then you might want to read about how to use the more complex Meta Query parameters. 技术支持 Support is handled in the WordPress forums. Please note that support is limited and does not cover any custom implementation of the plugin. Please report any bugs, errors, warnings, code problems at Github

安装:

  1. Upload the plugin folder to the /wp-content/plugins/ directory
  2. 通过WordPress的“插件”菜单激活插件
  3. Go to the plugin's settings and select which post types for which you'd like to show the featured metabox

屏幕截图:

  • The plugin settings
  • 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.
  • The metabox when editing an individual post

更新日志:

1.4.0 1.3.2 1.3.1 1.3.0 1.2.4 1.2.3 1.2.2 1.2.1 1.2 1.1.4 1.1.3 1.1.2 1.1.1 1.1 1.0.1 1.0