前言介紹
- 這款 WordPress 外掛「Featured Item Metabox」是 2013-01-30 上架。
- 目前有 100 個安裝啟用數。
- 上一次更新是 2020-02-17,距離現在已有 1902 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 3.8 以上版本才可以安裝。
- 有 2 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
內容簡介
此外掛提供了一個可以在後台文章中加上「推薦」的勾選框,讓使用者可以容易地標註文章是否為推薦文章。本身此控制在 WordPress 中是使用「sticky posts」達成,但若為新使用者的話可能會不太直觀。此外掛可以在每篇文章中添加名為「_featured」的 meta key 及值為「yes」或「no」,讓開發者更容易取用並在主題樣板中自訂要如何顯示推薦文章。若網站同時有多個查詢需求,建議使用 Transients API 進行查詢暫存,以減少網站的負擔。使用 Transients API 的範例實作方式及相關程式碼可以參考上述內容。另外也提供了一個範例函數,可以在主題的 functions.php 中使用,讓當推薦文章更新時可以立即刪除暫存,以保持顯示的即時性。
原文外掛簡介
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.
Usage
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 '
- ';
- ' . get_the_title() . '
while ( $featured_portfolios->have_posts() ) :
$featured_portfolios->the_post();
echo '
';
endwhile;
echo '
';
else :
echo 'No featured portfolios found.';
endif;
/* Restore original Post Data
* NB: Because we are using new WP_Query we aren't stomping on the
* original $wp_query and it does not need to be reset.
*/
wp_reset_postdata();
Multiple queries per page load can slow down your site so it is worthwhile to take advantage of the Transients API, so an alternate usage would be:
// 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 '
- ';
- ' . get_the_title() . '
while ( $featured_portfolios->have_posts() ) :
$featured_portfolios->the_post();
echo '
';
endwhile;
echo '
';
else :
echo 'No featured portfolios found.';
endif;
/* Restore original Post Data
* NB: Because we are using new WP_Query we aren't stomping on the
* original $wp_query and it does not need to be reset.
*/
wp_reset_postdata();
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.
// 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
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
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Featured Item Metabox」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
1.0 | 1.1 | 1.2 | 1.0.1 | 1.1.2 | 1.1.4 | 1.2.1 | 1.2.3 | 1.2.4 | 1.3.0 | 1.3.2 | 1.4.0 | trunk |
延伸相關外掛(你可能也想知道)
Ocean Extra 》mplates IMPORT, With Ocean Extra, you get access to a wide range of both free and premium website templates to import to your website with a single...。
Post Type Archive Link 》Post Type Archive Link 外掛會在「外觀 > 選單」管理頁面上建立一個新增文章類型存檔頁面的元件。, 此元件將會列出所有自訂文章類型,並且允許您在 WordPres...。
Multi Image Metabox 》這個外掛新增了一個 metabox,允許在一篇文章中上傳和連結多張圖片。, 圖片是透過 meta_value(和附件 ID)連結。它們可以使用拖放重新排序。, 允許的圖片數...。
JM Twitter Cards 》啟用外掛後,它將在您的 WordPress 網站上添加適當的 meta,使您可以根據設置為您的文章獲得 Twitter 卡片。享受吧!, 功能, , Gutenberg 兼容,設有自定義側...。
Pure Metafields 》The Pure Metafields Plugin 是一個功能強大的工具,旨在提升和增加你的 WordPress 網站的功能和靈活性。使用這個外掛,你可以輕鬆地創建和管理自定義的 meta...。
Advanced Post Manager 》這是一個針對開發者所設計的工具,可以透過添加 metadata、taxonomy 等資訊來協助加強自訂文章類型的列表功能。此外,也提供直觀的介面讓您可以添加及儲存複...。
CubeWP – All-in-One Dynamic Content Framework 》CubeWP Framework 是給 WordPress 開發人員的「鋼鐵人戰衣」。, CubeWP Framework 是最終的動態內容解決方案,可讓您以最短的時間活力您的想法,無需複雜的編...。
WebMan Amplifier 》, 在您評價/評論插件之前:, 請注意,此外掛是為WordPress主題開發人員而創建的。如果您是一般的、不精通技術的WordPress使用者,這個插件將會讓您失望,您不...。
Template List Metabox 》這個外掛可以讓你選擇自訂文章類型並顯示模板清單的下拉式選單。, 在前端,這個外掛可以幫助你顯示文章所選擇的模板。, 現在,你可以像頁面一樣每個文章都選...。
Gallery Metabox 》注意:此插件使用舊版媒體庫介面,開發者沒有計劃更改此功能。, 我經常在我所建立的網站上使用 WordPress 圖庫。它是一個很棒的工具,但很難找到。因此,我創...。
Categories Metabox Enhanced 》感謝由 WebDevStudios 創建的套件 Taxonomy_Single_Term,讓我在開發這個外掛時更輕鬆。, 使用分類增強型資訊框,您可以:, , 將內建分類資訊框/面板改為單一...。
Attesa Extra 》Attesa Extra 是專為 Attesa WordPress 主題 設計的外掛,提供更多自訂範本、小工具、Elementor 小工具及 metaboxes 等功能,讓您能針對每個文章/頁面編輯網...。
Source Affix 》來源附註(Source Affix), 如果您希望在您的文章中添加來源鏈接,則此外掛正是適合您的。它添加了一個獨立的元框用於輸入來源文本。您可以將此功能用於任何文...。
WP User Profiles 》WP User Profiles 是在 WordPress 中編輯使用者的複雜方法。, , 包括 WordPress 本身的所有功能, 包括 4 個頂級 “Sections”, 包括一個 “Other” 部分,可以自...。
Multi Image Upload 》該外掛新增了一個元框,以上傳多個圖片到文章和頁面。你也可以啟用它用在自定文章類型,請參考安裝說明。, miu_get_images(), 此函數可從任何模板檔案中調用...。