0

I'm registering a custom post type 'events'. The events can be listed using a shortcode, and when you click on an event you go to the single view of that event. Now, I want this single view page to be styled completely different using all of the event's metadata to create maps, images, etc, but I cannot figure out how. Using a template for this single view isn't an option since this is a plugin and should work with any theme. Just filtering the post's content isn't enough as I want to style the title too.

Any ideas? Thanks in advance!

1
  • You can filter the title also.
    – cybmeta
    Commented Jul 26, 2014 at 19:24

1 Answer 1

0

There's at least 3 options to choose from:

You can use the single CPT file name which you can grab from the source code in the body classes or a custom class which can be added directly to the single-cpt.php file or using a functions file with conditional tag.

.single-cpt {
your declarations
}

Or add directly to single-cpt.php file

add_filter( 'body_class', 'wpsites_cpt_body_class' );
function wpsites_cpt_body_class( $classes ) {
   $classes[] = 'your-single-cpt-class';
   return $classes;
}

Or with conditional in functions file

add_filter( 'body_class', 'wpsites_cpt_body_class' );
    function wpsites_cpt_body_class( $classes ) {
if ( is_singular('your-cpt') ) {
       $classes[] = 'your-single-cpt-class';
       return $classes;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.