WordPress condition judgment tag detailed list

Different templates can be loaded for a specific page by using WordPress condition judgment tag. Using WordPress condition judgment tag flexibly can make WordPress picture list, special topic page, different article page, etc. Usually, I use these condition tags to output different keywords and description tags for different pages.

Detailed list of WordPress condition judgment Tags

Home Page

is_ home()

Home page, return true when the current page is home page, return true only when the home page display setting in “reading” setting is “latest article”

Home Page

is_ front_ page()

Home page, no matter what the value of home page display setting in “reading” setting is, returns true. It should be noted that when the home page display is set to a static page, your site’s home page is loaded page.php Page template.

administrator panel

is_ admin()

In the background, it returns true only when it is in the background of the website. It is usually used for plugin development, because the theme template is always loaded in the foreground.

Article page

is_ single()

Judge whether it is an article page

is_ single(’18’)

Article page with ID 18

is_ single(‘new post’)

Article page titled “new post”

is_ single(‘new-post’)

Article page with alias “new post”

is_ single(array(18,’new-post,’new post’))

If the article ID is 18, the alias is “new post” or the title is “new post”, it will return true, that is, it will return true as long as one of the conditions is met

articles at the top

is_ sticky()

To determine whether the current article is at the top, it must be used in the main loop

is_ sticky(’18’)

Judge whether the article with ID 18 is at the top

comments

is_ comments_ popup()

Judge whether it is a pop-up comment

comments_ open()

To judge whether comments are allowed or not, it must be used in the main loop

pings_ open()

To judge whether the article ping function is on or not, it must be used in the main loop

page

is_ page()

Judge whether it is a page

is_ page(‘8’)

Page with ID 8

is_ page(‘about me’)

Page titled “about me”

is_ page(‘about-me’)

Page alias “about me”

is_ page(array(8,’about-me’,’about me’))

If the page ID is 8 or the alias is “about me” or the title is “about me”, it will return true, that is, it will return true as long as one of the conditions is met

user defined page template

is_ page_ template()

Do you want to customize the page template

is_ page_ template(‘ links.php ‘)

Do you want to customize the page template links.php

classification page

is_ category()

Judge whether it is classified page

is_ category(‘9’)

Category page with ID 9

is_ Category (‘wordpress template tags ‘)

Category page named “WordPress template tags”

is_ category(‘wordpress-template-tags’)

Category page with alias “WordPress template tags”

is_ Category (array (9, ‘WordPress template tags’,’wordpress template tags’))

If the category ID is 9 or the alias is “WordPress template tags” or the name is “WordPress template tags”, it will return true, that is, it will return true as long as one of the conditions is met

in_ category(‘6’)

If the current article is in the category with ID 6, it returns true

tab page

is_ tag()

Determine whether it is a label page

is_ tag(‘wordpress-template-tags’)

Label Page alias “WordPress template tags”

is_ tag(array(‘wordpress-template-tags’,’html’,’css’))

If the alias of the current tag page is “WordPress template tags” or “HTML” or “CSS”, return true

has_ tag()

To determine whether the current article has a label, it must be used in the main loop.

has_ tag(‘wordpress-template-tags’)

Judge whether the current article has a label “WordPress template tags”

has_ tag(array(‘wordpress-template-tags’,’html’,’css’))

author page

is_ author()

Determine whether the author page

is_ author(‘2’)

Author page with ID 2

is_ author(‘jack’)

The author page nicknamed “Jack” can also use the name as a parameter

is_ author(array(2,’john-jones’,’jack’))

ID 2, nickname “Jack” or name “John Jones” will return true

date page

is_ date()

Determine whether to file the date page

is_ year()

Determine whether the current page is a page archived by year

is_ month()

Determine whether the current page is a page archived by month

is_ day()

Determine whether the current page is archived by date

is_ time()

Judge whether the current page is a page archived by hour, minute and second

archive page

is_ archive()

Determine whether to archive the page, including classification, label, author page, date archive page, etc

search results page

is_ search()

Determine whether to search the result page

404 page

is_ 404()

Judge whether the current page has “HTTP 404: not found” error

pagination page

is_ paged()

Pagination of archive pages, excluding pages split by <! — NextPage — >

attachment page

is_ attachment()

Determine whether it is an attachment page

is it an article page, page or attachment

is_ singular()

As long as is_ single()、is_ page()、is_ Attachment() returns true, and this function returns true

subscribe

is_ feed()

Determine whether to subscribe to the output page

citation notice

is_ trackback()

Determine whether the trackback function is enabled

preview

is_ preview()

Judge whether it is on the preview page

is there a summary

has_ excerpt()

Determine whether the current article or page has a summary, this function is very useful, can help us set the description label as summary content

has_ excerpt(’28’)

Judge whether the article with ID 28 has an abstract

is it in the loop or not

in_ the_ loop()

Determine whether it is in the main loop

whether the sidebar is activated

is_ active_ sidebar()

To determine whether the sidebar is active, you need to pass in the sidebar logo

Related Article
WordPress comment date tag: comment_date

WordPress template tags comment_ Date is used to output the date of a comment, usually in a custom comment template. Read more

WordPress comment summary tag: comment_excerpt

WordPress template tags comment_ Excerpt is used to output the summary of comments. The default output is 20 characters. It Read more

WordPress comment time tag: comment_time

WordPress template tags comment_ Time is used to output the publishing time of the current comment, which is the same Read more

WordPress RSS format comment author name tag: comment_author_rss

WordPress template tags comment_ author_ RSS is used to output the comment author name in RSS format, which has no Read more

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image