I am trying to add a css file specific to 3 pages using the is_page(postid)
for a WordPress website in the functions.php
if (is_page(1) || is_page(2) || is_page(3) ) {
echo "<script>console.log('insideIf');</script>";
wp_enqueue_style( 'custom_css', get_template_directory_child() . path);
}
So considering 1,2 and 3 are the ids of the pages, the pages with the ids 2 and 3 are logging the message in the console and loading the css file whereas is_page(1)
does not respond.
I tried changing it to is_page('1')
or is_single()
or is_single(1)
. The page that is not getting detected is a blog page and i even tried with the title is_page('blog')
.
Ps. Cross checked the id many times, so I am definitely not using the wrong id.
1
is set as static posts page (Dashboard -> Settings -> Reading) try to useis_home()
. Look at here