Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress How to Check whether it is POST or PAGE

Tags:

wordpress

How to check if an article is a post or a page in WordPress?

like image 935
KillerFish Avatar asked Nov 27 '10 06:11

KillerFish


People also ask

How do I find the post type for one page in WordPress?

You can use the is_page() and is_single() functions. Show activity on this post. You can also use get_post_type() function.

What is Is_page () function in CMS?

is_page( int|string|int[]|string[] $page. Determines whether the query is for an existing single page.

How do I get my WordPress page to show posts?

If you want your posts to show up on the home page and WordPress isn't already doing this for you, here's how you do it. In the WordPress admin, go to Settings > Reading. Find the section called Your homepage displays and select the Your latest posts option. Click the Save Changes button and go back to your home page.

Is a WordPress page a blog?

By default, WordPress displays blog posts on your homepage. This is just fine if your website is intended as a blog. But if you have a business website or your homepage is intended to highlight your products, services, or something else, you need a separate page for your blog posts.


2 Answers

You can use the is_page() and is_single() functions.

like image 57
joschi Avatar answered Nov 13 '22 14:11

joschi


You can also use get_post_type() function.

if (get_post_type() === 'post') {     // POST }  if (get_post_type() === 'page') {     // PAGE } 
like image 30
20AMax Avatar answered Nov 13 '22 12:11

20AMax