Here is something that I do not understand… I have roots installed on the http://3d-car-shows.com site. I have downloaded the latest roots theme, and activated on the server. Now suddenly (or after the new install) I cannot get is_single is_frontpage or is_singular or any of the others to work…
Eg I added the following line into functions.php under $roots_includes = array( ‘custom/posts.php’
); and kept the other includes intact…
I then created the custom/custom-posts.php page, where I want to check if a page is_single or is_home etc…
<?php
if (is_page()) {
echo "<h2>Front Page</h2>";
}
if (is_single()) {
echo "<h2>Front Page</h2>";
}
?>
Something like the code above… But for the live of me, I am not getting it to work…
Am I missing something? Any idea why this might not be working?
Hi CFX - It is because I have included it into the content-single.php file to make sure the is_single is working, if it sits inside the content-single.php page, that is why you are getting the output at the bottom…
if (is_single()) {
echo "<h2>Single</h2>";
However the other one should appear as a H2 on the top of the page…
This has nothing to do with Roots. If you’re using conditional tags within a file that’s outside of the WordPress template hierarchy then you will need to hook into an appropriate action.