[WordPress] 外掛分享: Simple Page Sidebars

首頁外掛目錄 › Simple Page Sidebars
WordPress 外掛 Simple Page Sidebars 的封面圖片
20,000+
安裝啟用
★★★★
4.9/5 分(54 則評價)
388 天前
最後更新
問題解決
WordPress 4.9+ v1.2.1 上架:2011-11-08

內容簡介

Simple Page Sidebars 設計簡單、彈性高,讓 WordPress 使用者、設計師和開發者不須更動任何模板,即可指定專屬側欄到個別頁面。現有的側欄也能在快速編輯和批次編輯模式中進行指定,省去您寶貴的時間。

與一些複雜外掛程式相比,Simple Page Sidebars 的目標是提供基本的核心功能和簡易使用的整合,而不會污染您的管理面板。而由於側欄的儲存方式,它使用內建的 WordPress 快取,因此您的網站不會被額外的查詢拖慢速度。

Simple Page Sidebars 還內建一個「Widget Area」小工具,能夠將一個側欄的所有小工具拉到另一個側欄。

優勢

不再是全站通用的側欄,每個頁面(或區段)都可擁有其獨特的小工具。
完全掌握您自訂側欄的名稱。
指定多頁面共用同一側欄。
修改頁面側欄時,不會產生不必要的版本。

進階使用

如果您想將自訂側欄指定到存檔頁面或替換每個頁面的多個側欄,這個外掛程式可能不是最佳解決方案。但它彈性高,可以處理大範圍以頁面為基礎的使用情境。您還可以透過加入幾行程式碼,讓它也支援自定文章類型:

function myprefix_init() {
add_post_type_support( '{{post_type}}', 'simple-page-sidebars' );
}
add_action( 'init', 'myprefix_init' );

其他資源

撰寫評論
在 GitHub 上貢獻
追蹤 @cedaroco
造訪 Cedaro

注意事項
自訂迴圈

如果您的頁面存在任何的自訂迴圈或查詢,它們需要在wp_reset_query()之後才能執行,否則全域的$post變數將不再參照正確的文章,當側欄顯示時,Simple Page Sidebars 將不知道當前檢視的是哪個頁面,可能導致顯示不符合預期的側欄。

主題側欄

有些主題為其頁面模板註冊不同的側欄,這代表沒有預設側欄可以被替換。不過您可以建立一個子佈景主題,強制將擁有自訂側欄的頁面模板使用預設側欄,進而在這種情況下使用 Simple Page Sidebars。

外掛標籤

開發者團隊

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

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

原文外掛簡介

Designed for simplicity and flexibility, Simple Page Sidebars gives WordPress users, designers, and developers the ability to assign custom sidebars to individual pages–without making any template changes. Existing sidebars can also be assigned in quick edit and bulk edit modes, helping save you time.
In contrast to some of the more complicated plugins available, Simple Page Sidebars aims for basic, core-like functionality and integration that’s easy to use without polluting your admin panel. And due to the way sidebars are saved, it utilizes built-in WordPress caching, so your site won’t be bogged down with additional queries.
Simple Page Sidebars also ships with a “Widget Area” widget for pulling all the widgets from one sidebar into another.
Benefits

No more site-wide, generic sidebars. Each page (or section) can have its own widgets.
Complete control over the names of your custom sidebars.
Assign the same sidebar to multiple pages.
Modify a page’s sidebar without creating an unnecessary revision.

Advanced Usage
If you want to assign custom sidebars to archive pages or replace multiple sidebars per page, this plugin likely won’t be the best solution. However it’s flexible enough to handle a wide range of page-based use cases. It can even be configured to work with Custom Post Types by adding a couple lines of code:
function myprefix_init() {
add_post_type_support( '{{post_type}}', 'simple-page-sidebars' );
}
add_action( 'init', 'myprefix_init' );

Additional Resources

Write a review
Contribute on GitHub
Follow @cedaroco
Visit Cedaro

Notes
Custom Loops
If your page has any custom loops or queries, they need to be followed by wp_reset_query(), otherwise the global $post variable will no longer reference the correct post and by the time the sidebar is displayed, Simple Page Sidebars won’t know which page is being viewed, possibly leading to an unexpected sidebar being displayed.
Theme Sidebars
Some themes register different sidebars for their page templates, which means there isn’t a default sidebar that can be replaced. To use Simple Page Sidebars in this instance, you can create a child theme and force page templates with custom sidebars to use the default sidebar.

延伸相關外掛

文章
Filter
Apply Filters
Mastodon