Conditional Widgets

外掛說明

重要注意事項:這個外掛在 WordPress 5.8 或更新版本經過改進的 [小工具] 畫面無法執行,因此必須安裝並啟用 Classic Widgets (傳統小工具) 外掛。這個外掛會為使用 Classic Widgets 的網站持續提供技術支援及維護,但沒有計畫支援區塊小工具。

This plugin adds a form to each widget on the Widgets panel which allows users to choose which pages and/or categories the widget is either displayed on or hidden from.

For each widget, you can choose criteria to either SHOW or HIDE the widget, based on a number of categories. The interface is quite intuitive, and requires no knowledge of php or conditional tags.

螢幕擷圖

  • Each widget gets an expandable form at the bottom of it for controlling display options on the home page and for both pages and categories.

安裝方式

Standard Installation Procedure

  1. Upload the cets-conditional-widgets folder to the /wp-content/plugins/ directory
  2. 在 WordPress 管理後台的 [外掛] 選單中啟用外掛。

常見問題集

這個外掛是否能搭配自訂內容類型或自訂分類法使用?

Yes and No.

Conditional Widgets can be configured with additional Type/Taxonomy pairs (both native and custom), similar to how it functions with Posts and Categories. However, it does not support additional Custom Post Types the way it does Pages. (If I were going to write it from scratch, I would have definitely included that, but have no plans to add it given that Widgets themselves are on the way to becoming unsupported.)

The following filter is available to take pairs of Post Type and Taxononmy slugs (use in functions.php or a small plugin):

// Add Conditional Widgets support for Success Stories (Post Type) & Story Groups (Taxonomy)
add_filter('conditional_widgets_type_tax_pairs', 'success_story_conditional_widget_type_tax_pairs' );

function success_story_conditional_widget_type_tax_pairs( $pairs_array ) {

    $success_story_pair = array(
        'type'=> 'success-story',
        'tax'=> 'story-group' 
    );

    $pairs_array[] = $success_story_pair;
    return $pairs_array;

}

If you really want to be able to use Conditional Widgets to control Widget display on individual instances of a Custom Post Type (rather than based on a Taxonomy), the workaround would be to create unique Taxonomy terms for those Custom Posts.

使用者評論

2020 年 8 月 24 日
I have been looking for such a widget for some time, and found it today. It is working with wp 5.5. Thank you for the plugin.
2019 年 4 月 5 日
Very useful plugin, light, easy to use for customizing each category widget, or page too, it works very well. Thanks -:)
2018 年 8 月 25 日
Hi, I see that this plugin is no longer followed by its developer for a long time, to delete?
閱讀全部 24 則使用者評論

參與者及開發者

以下人員參與了開源軟體〈Conditional Widgets〉的開發相關工作。

參與者

〈Conditional Widgets〉外掛目前已有 7 個本地化語言版本。 感謝全部譯者為這個外掛做出的貢獻。

將〈Conditional Widgets〉外掛本地化為台灣繁體中文版

對開發相關資訊感興趣?

任何人均可瀏覽程式碼、查看 SVN 存放庫,或透過 RSS 訂閱開發記錄

變更記錄

3.3

    Updated tested to version, documented support for custom post type and taxonomy support

3.2

  • Tested through version 6.5.5

3.1

  • Added message to readme explaining the future of Conditional widgets after WordPress 5.8

3

  • Improved string translatability (Props @alexclassroom)

2.2

  • New Features: Hide on Desktop / Hide on Mobile. (Note that using either of these options will immediately hide the widget when the condition is true, and any other options to ‘show’ will be ignored.
  • Fixes lots of small bugs related to the display of the widget control form

2.1

  • Major update of code formatting to better align with WordPress style and guidelines – props @cFoellmann
  • Support Conditional Widgets toggle JavaScript on the Customize screen

2.0.5

2.0.1

  • Major Rewrite: modified how settings are stored.

1.8

  • Added an additional checkbox for ALL pages/categories to, once again, make the UI even easier to understand

1.7

  • Added VERY basic string translation support
  • Tweaked UI surrounding pages/categories to be easier to understand

1.6

  • Only display the informative debugging text when WP_DEBUG_DISPLAY is true
  • More verbose informative debugging text

1.5

  • Fixed a bug surrounding the extra conditional checks on some configurations (Thanks, mmcginnis!)
  • Added debugging and informative statements while WP_DEBUG is enabled

1.4

  • Added support for Posts Pages (when using Static Front Page)

1.3

  • Added support for saving options on Widgets that didn’t otherwise have options

1.2

  • Added option for Tag Archives (by request)

1.1

  • Added options for Search, 404, Date Archives, and Author Archives

1.0.2

  • Small edit to play nicely with some other plugins and their additional processing

1.0.1

  • Basic bug fixes: resolved some warnings and errors. (Sorry for the inconvenience.)

1.0

  • Initial Release