當我們進入一個頁面,比如首頁,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