SiteCozy

  • My account

WordPress conditional tags reminder

2018-10-25

Homepages

  • The following condition matches when the homepage is a static page: is_front_page()
  • The following condition matches when the first page is a page of the blog: is_home()

Post

  • This condition will match on every post: is_single()
  • If the current post has the following title: is_single(‘this is the title’)
  • If the current post has the following slug: is_single(‘this-is-the-slug’)
  • If the current post has the following ID: is_single(‘123’)

Page

  • This condition will match on every page: is_page()
  • If the current post has the following title: is_page(‘this is the title’)
  • If the current post has the following slug: is_page(‘this-is-the-slug’)
  • If the current post has the following ID: is_page(123)

Category

  • If the current page is a category page or a taxonomy page or a tag page: is_archive()
  • If the current category has the following title: is_category(‘this is the title’)
  • If the current category has the following slug: is_category(‘this-is-the-slug’)
  • if the current category has the following ID: is_category(‘9’)

Special pages

  • When the page returns a 404: is_404()
  • When the page is the result of a search: is_search()
  • When the page is an author: is_author()
  • A page with the following author ID: is_author(‘1’)
  • A page with the following author slug: is_author(‘john-doe’)
  • A page with the following author name: is_author(‘john doe’)

Related Posts:

  • CRP, the best related posts plugin for WordPress
  • Yuzo related posts plugin by Ilen review
  • WP category pages excerpt vs full content & SEO
Download our Broken link checker freeware here Buy a license key for the Sitecozy broken link checker

Customer Login

Lost password?

Categories

  • Webmaster advice
  • SEO advice
  • Web hosting
  • SiteCozy link checker KB
  • WordPress theme & plugin reviews
  • All articles
Disclosure: We are a professional review site that receives compensation from the companies whose products we review. We test each product thoroughly and give high marks to only the very best. We are independently owned and the opinions expressed here are our own.

Copyright Sitecozy 2018