You can use the following instead,
if (is_singular('post')) {
//your code here...
}
Where by is_singular
is the WordPress API conditional function for testing for the existence of a post type. You can also pass an array of post types if you wish.
Related Posts:
- Disable single post page
- Post type no single page
- Defined function isn’t showed on page
- Making a wordpress page print friendly
- Insert Shortcode exactly at the end of the content
- Show Next/Previous without Link
- How to change the case of all post titles to “Title Case”
- Function to execute when a post is moved to trash .
- Custom Single Post By Category
- Using single.php from plugin folder instead of default template folder
- Fatal error: Call to undefined function post_exists()
- Code to auto expire posts after 30 days
- Post X of Y in single.php / sidebar.php
- Keep a fluid max number of posts on site
- Custom colors for post rows based on post meta value
- How to add an admin function only to posts, not pages?
- Custom wp_trim_words() function not trimming right
- Why does `url_to_postid` return 0 when testing `page_for_posts` Page?
- custom single.php not working
- Delete Post From Front-End and attachment permanently
- Limit function to specific post category
- When paginating a Page with the tag, how can the 2nd and subsequent page styles be customised?
- Function to show random posts from a category
- Hiding posts in a list from specified categories
- how load content as pop-up using ajax
- Checking is user author of number of posts?
- Create cron job without a plugin?
- How to rename “Publish” metabox title in post screen
- Restrict post navigation to current sub menu
- Action hook for new pending posts?
- Uppercase first sentence in every post
- Add icon/badge next to posttitle of specific category
- Ajax posts filter by date, comments, top views, top likes
- Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
- Why content_arr[‘extended’] removes paragraph tags?
- How to show single post page as home page
- Using wp_list_categories like the the_category (showing just current categories of a post)
- How can I make a post that belongs to a category or have specific tags, display different from the other single posts?
- Display all posts that were published before full post on single.php
- Force the “Choose from the most used tags” meta box section to always be expanded
- Show the content that is after the excerpt using child theme
- How to allow users to post only in certain category and hide elements from edit page?
- Add Read More Tag to a post content (Single.php)
- Display post x of y within category
- WordPress Automatic Filename Changer
- Order posts alphabetically: how to set order=asc in mysql query?
- Insert sometext after first h3 in content
- Thumbnail Image to go in the post aswell
- Is it possible to customize the post according to post format in single.php?
- Adding a user’s ID behind the tag ref link address
- How to check in functions.php if there is data in a WP_Query?
- WordPress 302 Redirect to Random Product/Post/Page
- Getting Whitescreen when publishing a post [closed]
- Get post by tag
- Add code to a specific post’s content
- Related Posts: Changing Function For Posts Per Page
- Query function not executed between element [closed]
- Optimize CPT-function with a loop
- Changing wp_link_pages() to “Next Page” and “Previous Page” buttons?
- “Home” Page now only displaying the single latest post
- Set Default Post as Parent Child (Nested) Relation
- I need to create “View Profile” and “Edit Profile” links by incorporating the Post Title/ID, but can’t seem to manage it
- How to put the author of the post in the comments?
- Check if almost 10 year old – working code is up to date
- WordPress Sticky Post Count “Fix” Breaking Pagecount by 72 pages!
- Function is printing twice – any suggestions?
- How to add a custom class attribute into code wrapper? [duplicate]
- WP posts using index.php instead of single.php
- Remove pagination if search returns empty
- Remove HTML tags from all posts
- Single post shows post three times
- I want to change the WordPress comments file
- Excluding tag Link from html tags in Post content
- Save All Post Permalink From A Specific Category into a .txt file
- How do I check if a post is password protected?
- Changing a users posts to drafts upon role change
- How to Display Most View Post in the template file?
- display multiple posts and posts content on a single URL
- Show post excerpt
- How do I apply a wordpress function to something with no ID inside an archive page?
- Show all posts from the tags without having to set all of them
- Show author bio box
- Trim excerpt to first paragraph
- Get the category of post
- Custom Single Post Type not referring to single-post-type.php File
- Call image from post on index page?
- Thumbnail With Next/Prev Links Not Showing Next Post?
- How to edit label_submit styling?
- How do I get thumbnails?
- Pagination and Related Posts
- How to limit the number of results for all query_posts on mysite
- Single post page from static home not working
- Get current post’s child page?
- User driven content problems
- Notify Author of the post if admin deletes his post and perform some function
- How do we display a certain category type on a page while hiding all others?
- Wrap div-tag around posts in page
- What function does the loop of displaying posts?
- how show post date for specific post?
- Filters do not work when there are multiple (one works)