How to check if an article is a post or a page in WordPress?
相关问题
- Display product ACF field value in Woocommerce tra
- Adding a custom button after add to cart button in
- How to add a “active” class to a carousel first el
- Setting custom order statuses as valid for payment
- change the font size in tag cloud
相关文章
- wordpress新增页面如何个性化设置
- select query in wordpress
- Get WooCommerce featured products in a WP_Query
- Woocommerce update shipping methods in checkout vi
- Change order status just after payment in WooComme
- Publishing or uploading failed. Error message: “Th
- Facebook Login With WP JWT Auth
- Wordpress development process
It's for developer, if you are not a developer you can also check current page type. You have to just inspect particular page and see body tag. If theme is build with basic WordPress rules then body tag have classes related to page or single page. These classes may b included the post type, template name, file name, page id and many more.
You can use the is_page() and is_single() functions.
If you're looping through a collection of posts/pages (say, on a search results page), then
is_single()
andis_page()
won't be of any use. In this situation, you could grab the global$post
object (of typeWP_Post
) and examine the$post->post_type
property. Possible values include 'post' and 'page'.is_singular() returns true for a single post, page or attachment
You mean that
is_single()
will return true if it is a post ? (not a page), am I right,I like that, I think you wrong, because I have a plugin show some text on only post, I'm using
is_single()
but It also show on pages.Please advice.
Thanks
if you want y¡to know the page that list the posts , and you are using the posts page option in the configuration, You should use
is_home()
.