WordPress page location and ID classification location function

Source: Internet
Author: User

 

Below are common page judgment statements


Is_home () === home page
Is_single () === article page
Is_page () === Page
Is_category () === document category page
Is_tag () === Article tab
Is_archive () === archive page
Is_404 () ==== page 404
Is_search () === search result page
Is_feed () === Subscription Page

 

How can we use these statements? For example:

If I want to set the word "Skyball homepage" to only display on the homepage, this is the case. <? Php if (is_home () {?> Skyball homepage <? Php }?>

In the preceding example, the yellow and bold parts can be replaced at will. You can determine how to display is_single () [only on the document Page] or is_archive () [Archive page], etc.

Since it can be set to display only a certain content on a page, can it be set to prohibit the display of the same content only on a certain page? The answer is yes.

Syntax note: | represents or, & represents and ,! The preceding syntax allows you to define the page display content more flexibly. The Syntax example is as follows:


! Is_home () ==== all pages except the home page are displayed
! Is_category (4) ==== is only displayed in a category where ID is not 4
Is_home () | is_category ('movies') ==== displays the categories named movies on the home page.
Is_page ('about') ==== displayed only on the page named 'about'
Is_home ()&&! Is_paged () ==== displayed on the homepage, not displayed on the page

A Tag Page Tag archiving
Is_tag ()
Determines whether it is a tab
Is_tag ('mild ')
The Tag Archive page that determines whether it is an alias 'mild.
Is_tag (array ('sharp ', 'Mild', 'extreme '))
Determines whether the alias is a "sharp", "mild", or "extreme" tag archive page.
Has_tag ()
Determine whether the current article has tags.
Has_tag ('mild ')
Judge whether the current article has the tag 'mild '.
Has_tag (array ('sharp ', 'Mild', 'extreme '))
Determines whether the current article contains tags in an array.
  
A Taxonomy Page category Page
Is_tax ()
When any category archiving page is displayed, is_tax () returns TRUE ..
Is_tax ('mild ')
Is_tax ('mild') returns TRUE when the alias of the classification archiving page is "mild.
Is_tax (array ('sharp ', 'Mild', 'extreme '))
When the archive alias of the current category is "sharp", "mild", or "extreme" in the array, is_tax (array ('sharp ', 'Mild', 'extreme ')) returns TRUE.
  
A Registered Taxonomy Registered category
Is_taxonomy ()
If a category is registered through register_taxonomy (), is_taxonomy () returns TRUE.
  
An Author Page Author Archive
Is_author ()
Determine whether the archive page is the author.
Is_author ('4 & prime ;)
The author's archive page for determining whether it is id4.
Is_author ('Vivian ')
The author archive page that determines whether it is nicknamed "Vivian.
Is_author ('John-jones ')
Determines whether it is the author archive page nicknamed "john-jones.
Is_author (array (4, 'John-jones ', 'vivianc '))
Determine whether it is ID 4, "john-jones", or the author tab with the nickname "Vivian.
  
A Date Page Date archiving Page
Is_date ()
Determines whether it is a date archiving page.
Is_year ()
Determines whether the archive page is by year.
Is_month ()
When a monthly archive is being displayed.
Is_day ()
Determines whether the page is archived by day.
Is_time ()
Determines whether the archive page is archived by hour, minute, or second.
  
Any Archive Page
Is_archive ()
Whether to archive the page.
  
A Search Result Page
Is_search ()
Whether to search pages.
  
A 404 Not Found Page
Is_404 ()
Whether the page is 404.
  
A Paged Page
Is_paged ()
Determine whether there is a page. You need to <! -Nextpage-> Insert a quick tag to an article to split the article into multiple pages.
  
An Attachment
Is_attachment ()
Determine whether the file is an attachment. The attachment is an image or other file uploaded through the editor upload tool. The attachment can be displayed on the corresponding page or template.
  
A Single Page, Single Post or Attachment independent Page, Single log or Attachment
Is_singular ()
If is_single (), is_page (), or is_attachment () returns TRUE, is_singular () also returns TRUE ..
Is_singular ('book ')
True when viewing a post of the post type book. Introduced with Version 3.0.
Is_singular (array ('newspaper ', 'book '))
True when viewing a post of the post type newspaper or book. Introduced with Version 3.0.
  
A Syndication
Is_feed ()
When a website needs to use RSS to subscribe, is_feed () returns TRUE. Generally, the is_feed () tag is used by WordPress system and plug-in developers, and the is_feed () tag is rarely used by common WordPress users.
  
A Trackback reference notification
Is_trackback ()
The website needs to hook the WordPress hook into Trackback. The WordPress system and plug-in developers usually use this tag, and the is_feed () tag is rarely used by common WordPress users.
  
A Preview draft Preview
Is_preview ()
Determine whether the article is displayed in draft preview mode.
  
Has An Excerpt abstract
Has_excerpt ()
Determine whether the current article has a summary.
Has_excerpt ('42 & prime ;)
Judge whether the ID42 article has a summary.
  
Inside The Loop
In_the_loop ()
Determine whether the tag is in the WordPress main loop. This tag applies to plug-in developers. If the tag is currently in the WordPress main loop, TRUE is returned.
  
Is Sidebar Active Sidebar
Is_active_sidebar ()
Check whether the existing sidebar is activated (enabled). If the sidebar is enabled, is_active_sidebar () returns TRUE; otherwise, FALSE.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.