is_single()
returns TRUE
or FALSE
, not a string. Additionally, you can test for a specific post with is_single()
function by putting the post slug into the function call:
if ( is_single( 'your-post-slug' ) )
{
# do something
}
If you want to test for the proper post type use:
if ( is_singular() and 'your-post-type' === get_post_type() )
or just:
if ( is_singular( 'your-post-type' ) )
Edit
And for your specific question, you should wrap that script into a callback, hooked into wp_enqueue_scripts
. In functions.php
:
function wpse78368_enqueue_custom_stylesheet() {
if ( is_singular( 'pretty-little-liars' ) ) {
wp_enqueue_style(
'style-pll',
get_template_directory_uri() . '/posttypecss/style-pll.css'
);
}
}
add_action( 'wp_enqueue_scripts', 'wpse78368_enqueue_custom_stylesheet' );
Note: Use wp_enqueue_scripts
because wp_enqueue_styles
doesn’t exist as a do_action()
.
Related Posts:
- is_singular won’t call my functions?
- Date archives for custom post type
- How to get a list of term names of the custom post type im currently on in single.php
- Disable single pages and archives and keep preview
- Need post_type_archive_title function but in ‘single’
- How to show the archive / post type description on Single templates
- Changing number of posts per page on CPT-archive.php, have tried 20-30 code chunks so far
- get the custom post type title/name
- Custom post type – get_day_link()
- Get term name without a foreach loop
- Cant get paginations on single.php to work with my custom post types
- Including all post id’s of a custom post type into an array
- How do I add custom HTML to the content of an archive page’s posts?
- Can’t access private custom posttype single- or archives-page
- Menu’s breaking, now showing all page links on site
- How can I increase the post count for custom post types only?
- WordPress sitemap with Custom Post Types
- Do not show child pages within a file page
- Tell wordpress to show a single page instead of an archive page
- How to make a list of posts displaying them 5 by 5 with a “next posts” link?
- Stop header code from showing in category page?
- Different options per post type in WP_Query
- Only show posts with a specific term of an associated taxonomy in a custom post type archive
- After creating Custom post type by user delete old one
- Archive links for custom post types
- widget_posts_args not using the number of posts in widget
- Show All Custom Post Types On A Single Archive Page
- Show message when query has no posts
- Create short URL with auto 301 redirect
- How To Post WordPress Custom Post Types to Twitter via IFTTT
- Pagination hitting 404 page on /page/4
- Get data from PHP to JavaScript to set position of each post on front page
- Undefined $post in wp_query
- Get posts from Custom Taxonomy
- Use the custom post type archive for taxonomies?
- How do I create a new post upon registration with the users first and last name as title
- Removing full title and breadcrumb header container for a specific post type
- Is it possible to use array_walk() to append terms to an array of posts?
- How do I find a way to create a global single.php for a custom post type?
- How to rewrite custom taxonomy term archive to use THE SAME SLUG/front as CPT
- Query entries from custom post type in an ACF flexible content field
- get_post_types() can’t get some of my post type
- Creating a non-hierarchical Taxonomy that behaves like categories
- How to use single.php for creating, reading and editing Custom Posts with ACF
- Creating shortcode id for custom post types
- When I choose category from dropdown then everything working fine.But in backend it checked only child not parent [closed]
- Shortcode is displaying the content on top of the page [duplicate]
- get_terms() returns Trying to get property of non-object error for custom taxonomy
- Filter content in shortcode
- Query custom post types & Taxonomies and list them in a table on a page
- Custom Post Type setup
- Archive Page for Multiple Custom Post Types
- Custom post type and custom taxonomy 404 on page 2
- Creating a “glossary” of WordPress posts of a specific post type
- Show current user posts in custom post type query
- Using Pagination for Custom Post Type and keeps returning 404
- Custom Ratings for Theme, Proper way to Refactor Code and Clean up Template File
- How to show custom field on specific custom post type posts only when filled
- Display Date & Author Info on Custom Post Type Archive Page
- Importing JSON feed giving Notice: Array to string conversion error
- How to add new post using a form to categories when categories are using as menu
- How to set the mainpage of a custom post type?
- Different post title, keywords and description
- post_content is stripping HTML when adding a new post? [closed]
- custom post type by author – wp job manager
- Querying a custom post type, but not show duplicates
- Nested Custom Taxonomies | Incorrect posts when querying
- List latest post out of 2 custom post types
- How to constrain the results to a specific post_type on tag archive page?
- I’m trying to create a custom version of the wp_list_authors function that includes custom post types
- Get the link of the first post of a custom taxonomy in a custom taxonomy list
- adding custom post type “name” to single template
- Validate Custom Post Type fields
- meta query not retrieving posts
- Using Wp_Query, Json to add Highcharts series data
- How can I relate custom post types?
- Template code to split a post and print a custom field?
- Dynamic category name in query post
- How do I get the index for a custom post?
- Commas not displaying in implode
- add custom tags for custom post type in wordpress
- Accessing a protected property of a post
- Custom Post Type Archive Pagination
- Different column width in 2 rows with bootstrap and custom post types-different classes needed
- trying to show single post but displays all post on a custom post type
- How do I show my containing my custom field ONLY if there is a set value on that custom field? [closed]
- CPT Repeatable Fields + Undefined Index
- Displaying One Custom Post Type’s Content On Single Post of Another Custom Post Type
- foreach loop inside the loop creating duplicates in output
- How to know which archive page is active
- Need to have an archive widget which organizes and displays a custom post type using a custom date field
- Let users upload image(s) to the post from front end
- Custom Post Type Specific Post Template
- Foreach loop returning more than one item when querying taxonomy
- Function to erase every post from a taxonomy
- Archive page for custom post type and custom taxonomy
- Compare Two Custom Post Types Using The Same Custom Taxonomy
- Using page title as a link to term archive
- Archive Template being used instead of Category Template for Custom Post Type
- Why does my URL keep returning 404 error code?