This looks almost correct. Let’s have a look at is_single()
:
Works for any post type, except attachments and pages…
So if the given ID isn’t that of a page
or attachment
post type then you can use the function as so:
if( is_single( 2578 ) ) {
/* ... */
} else {
/* ... */
}
Otherwise, if the ID is a page
post type you can use is_page()
if( is_page( 2578 ) ) {
/* ... */
}
Should the ID be that of an attachment
page you may use is_attachment()
if( is_attachment( 2578 ) ) {
/* ... */
}
Finally, if you’re unsure of the post type you could check against the global $post
object, assuming it is correct:
global $post;
if( is_object( $post ) && 2578 == $post->ID ) {
/* ... */
}