How to check if an article is a post or a 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.
is_page( int|string|int[]|string[] $page. Determines whether the query is for an existing single page.
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.
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.
You can use the is_page() and is_single() functions.
You can also use get_post_type() function.
if (get_post_type() === 'post') { // POST } if (get_post_type() === 'page') { // PAGE }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With