How do I add my Custom Post Type "Single" items to this functions command?

add_action( 'wp_head', function () {
  if( is_tax('country') || is_page('4090') ){
  @media (max-width: 768px) {
    .site-content {
      display: flex;
      flex-direction: column-reverse;
} );

The above works great but I would also like to apply it to my Custom Post Type that is called:


I'd like the same function to apply also to all pages within the CPT "conference_2021"

I thought this would work but it doesn't:

if( is_single('conference_2021') || is_tax('country') || is_page('4090') ){

Am I missing something when trying to apply this to a CPT?


Both is check single post existing or not.

But both function argument is different.

is_singular(). Pass argument for this post type slug

is_single() Pass argument for post ID, slug, title.

If you are use is_single() then check post type name.

Like: if ( is_single() && 'conference_2021' == get_post_type() ) { }

Ref: https://developer.wordpress.org/reference/functions/is_singular/ https://developer.wordpress.org/reference/functions/is_single/

  • 1
    Yes, is_singular() should be used, but the docs for is_single() says, "Works for any post type, except attachments and pages". - and the main difference between the functions, is that is_singular() accepts a post type slug, whereas is_single() accepts the post data like ID or slug. – Sally CJ Feb 13 at 6:37
  • 1
    yes right. i updated my answer – Jignesh Patel Feb 13 at 6:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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