当我们进入一个页面,比如首页,Wordpress核心程序会判断当前页面。
Conditional Tags
TOPICS
Where to Use Conditional Tags
The Conditions For
The Main Page
The Front Page
The Administration Panels
A Single Post Page
A Single Post, Page, or Attachment
A Sticky Post
A Post Type
A Post Type is Hierarchical
A Post Type Archive
A Comments Popup
Any Page Containing Posts
A “PAGE” Page
Testing for Paginated Pages
Testing for Sub-Pages
Is a Page Template
A Category Page
A Tag Page
A Taxonomy Page
A Registered Taxonomy
An Author Page
A Multi-author Site
A Date Page
Any Archive Page
A Search Result Page
A 404 Not Found Page
An Attachment
A Single Page, Single Post or Attachment
A Syndication
A Trackback
A Preview
Has An Excerpt
Has A Nav Menu Assigned
Inside The Loop
Is Sidebar Active
Part of a Network (Multisite)
Main Site (Multisite)
Admin of a Network (Multisite)
An Active Plugin
A Child Theme
Theme supports a feature
Working Examples
Single Post
Check for Multiple Conditionals
Date Based Differences
Variable Sidebar Content
Helpful 404 Page
In the theme’s footer.php file
Conditional Tags Index
Function Reference
Conditional Tags can be used in your Template Files to alter the display of content depending on the conditions that the current page matches. They tell WordPress what code to display under specific conditions. Conditional Tags usually work with PHP if /else Conditional Statements.
The code begins by checking to see if a statement is true or false. If the statement is found to be true, the first set of code is executed. If it’s false, the first set of code is skipped, and the second set of code (after the else) is executed instead.
For example, you could ask if a user is logged in, and then provide a different greeting depending on the result.
————————————————
版权声明:本文为CSDN博主“赵蔚冬”的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u012809520/article/details/98969714