is_singular won’t call my functions?

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().

Leave a Comment