內容簡介
這個外掛為內容開發人員提供了類似於 WordPress 主題開發提供的條件標籤的短碼。每個短碼只在特定條件為真時包括其內容。這使得他們能夠根據每個帖子的情況修改所顯示的內容。is_page、is_single 和 is_category 通過使用「ids」參數允許指定特定頁面、帖子和分類。
以下是各個短碼及其包含內容的情況:
- is_single - 如果正在顯示單個帖子。使用可選參數“ids”來指定特定的帖子。
- is_singular - 如果正在顯示單個帖子或頁面。
- is_page - 如果正在顯示頁面。使用可選參數“ids”來指定特定的頁面。
- is_home - 如果正在顯示博客主頁。
- is_front_page - 如果正在顯示網站的首頁。
- is_sticky - 如果當前的帖子或頁面是“置頂”的。
- is_category - 如果正在顯示基於分類的存檔。使用可選參數“ids”來指定特定的分類。
- is_page - 如果正在顯示頁面。
- is_tag - 如果正在顯示基於標籤的存檔。
- is_tax - 如果正在顯示基於標籤或分類的存檔。
- is_author - 如果正在顯示基於作者的存檔。
- is_archive - 如果正在顯示任何存檔。
- is_year - 如果正在顯示年度存檔。
- is_month - 如果正在顯示月度存檔。
- is_day - 如果正在顯示每日存檔。
- is_time - 如果正在顯示每小時或更短的存檔。
- is_feed - 如果正在生成訂閱。
- is_search - 如果正在顯示搜索結果。
- comments_open - 如果當前的帖子或頁面的評論是開放的。
每個短碼還有一個“else”短碼,可以放在其中。例如:
```
[is_single]
This is only shown if showing just this post.
[not_single]
This is shown everywhere else.
[/is_single]
```
is_page、is_category 和 is_single 短碼允許您指定要顯示內容的頁面、分類和帖子,如果您只想在特定頁面、帖子或分類中顯示短碼內的內容,則可以使用此功能。
例如:
```
[is_page ids="76, 339"]hello[/is_page]
[is_category ids="5, 7"]hello[/is_page]
[is_single ids="94, 63"]hello[/is_single]
```
通常,“else” 短碼只是將“is”替換為“not”。唯一的例外是 not_comments_open,它是 comments_open 的“else”短碼。
無論包含哪個內容,都會處理短碼,因此您可以使用所有其他短碼,甚至將這些短碼嵌套,如果需要的話。
更多信息,請參見 WP Conditional Shortcodes Homepage。
外掛標籤
開發者團隊
原文外掛簡介
This plugin gives content developers shortcode equivalents to the conditional tags that WordPress provides for theme developments. Each shortcode only includes its contents if a certain condition is true. This allows them to modify what content is shown in any given context on a post-by-post basis. is_page, is_single and is_category allow specific pages, posts, categories to be specified by using the “ids” parameter.
The shortcodes and when they include contents are:
is_single – if showing a single post. Use the optional parameter “ids” to specify specific posts.
is_singular – if showing a single post or page.
is_page – if showing a page. Use the optional parameter “ids” to specify specific pages.
is_home – if showing the blog home.
is_front_page – if showing the front page of the site.
is_sticky – if the current post or page is ‘sticky’.
is_category – if showing a category-based archive. Use the optional parameter “ids” to specify specific categories.
is_page – if showing a page.
is_tag – if showing a tag-based archive.
is_tax – if showing a tag- or category-based archive.
is_author – if showing an author-based archive.
is_archive – if showing any archive.
is_year – if showing a yearly archive.
is_month – if showing a monthly archive.
is_day – if showing a daily archive.
is_time – if showing an hourly or shorter archive.
is_feed – if generating a feed.
is_search – if showing search results.
comments_open – if comments are open for the current post or page.
Each shortcode also has an “else” shortcode that can go inside it. For example:
[is_single]
This is only shown if showing just this post.
[not_single]
This is shown everywhere else.
[/is_single]
The is_page, is_category and is_single shortcodes allow you to specify pages, categories, posts on which to show the content if you’d like to only show content within the shortcode on specific pages, posts or categories.
[is_page ids="76, 339"]hello[/is_page]
[is_category ids="5, 7"]hello[/is_page]
[is_single ids="94, 63"]hello[/is_single]
In general, the “else” shortcode is just replacing “is” with “not”. The one exception is “not_comments_open” as the “else” shortcode for “comments_open”.
Whichever chunk of content is included is processed for shortcodes, so you can use all your other shortcodes and even nest these if you need to.
Further Instructions
Any other information I have can be found at the WP Conditional Shortcodes Homepage.
