[WordPress] 外掛分享: Tidyhive Featured Posts

首頁外掛目錄 › Tidyhive Featured Posts
WordPress 外掛 Tidyhive Featured Posts 的封面圖片
60+
安裝啟用
尚無評分
3295 天前
最後更新
問題解決
WordPress 3.0.1+ v1.5.0 上架:2017-02-05

內容簡介

這個外掛可以讓使用者在不需要編輯每篇文章的情況下,僅需點擊一下即可標註某篇文章為精選文章。外掛還包含一個小工具(widget),可以顯示所有被標記為精選文章的文章清單。

使用方式

前往管理後台頁面。
點選所有文章頁面,以顯示文章列表。
每行資料中都有一個名稱為「精選文章」的欄位,其中包含一個星型圖示。
按下星型圖示即可將該篇文章標註為精選文章。

儀表版 -> 文章 -> 所有文章

說明

Q1. 如何顯示精選文章清單?

此外掛提供了一個小工具,可以在側邊欄中加入使用。

Q2. 如何在主題的任何位置顯示精選文章清單?(開發者專用)

若要在您的主題中顯示精選文章清單,請使用以下程式碼來擷取文章:

$featured_posts = Thfp_public::thfp_get_featured_posts();

上述程式碼會回傳 WP_Query 物件,您可以使用迴圈來顯示文章。上述的靜態函式接受一個 (整數) 參數,用於限制它可以返回的文章數量。

使用自定義迴圈來顯示文章:

if($featured_posts->have_posts()):
while($featured_posts->have_posts()): $featured_posts->the_post();
//在此填入您的程式碼
endwhile;
endif;

您也可以使用自己的 wp_query。請確保您使用的 'tag' 鍵是 'featured'。

$args = array(
'post_status' => 'publish',
'tag' => 'featured',
//使用任何其他需要的引數
);
$featured_posts = new WP_Query($args);

然後,使用迴圈來顯示文章。

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.5.0) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Tidyhive Featured Posts」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

This plugin adds the ability for the user to mark a post to be a featured post with just one click without the need of editing an individual post. The plugin also includes a widget which can display all the posts which have been marked featured.
Usage

Go to your admin dashboard page.
Open all posts page which displays the list of posts in table.
A column name ‘Featured posts’ will be there with a star icon in each row.
Click the star to make that post as featured.

Dashboard->Posts>All Posts
Instructions
Q1. How to display feature posts?
Plugin comes with a widget, which can be added to sidebar
Q2. How to display featured posts in any desired section of theme(Developers)?
In order to display featured posts in your theme, use the following code to fetch the posts.
$featured_posts = Thfp_public::thfp_get_featured_posts();

The above code return WP_Query object which you can use in a loop. Above static function accepts a parameter(int) which limits the number of posts which it can return.
Show the posts with the help of custom loop:-
if($featured_posts->have_posts()):
while($featured_posts->have_posts()): $featured_posts->the_post();
//Your code here
endwhile;
endif;

You can also use your own wp_query. Make sure you use ‘tag’ key to be ‘featured’.
$args = array(
'post_status' => 'publish',
'tag' => 'featured',
//Use any other needed args
);
$featured_posts = new WP_Query($args);

and then use the loop to display posts.

延伸相關外掛

文章
Filter
Apply Filters
Mastodon