As this is an important question with no real answer, I will provide what I found after hunting a solution down, though I don’t have an answer as to why it doesn’t work like we all think it should.
You need to hook into WordPress somewhere, like this:
// load our posts-only PHP
add_action( "wp", "only_posts" );
function only_posts() {
if( is_single() ) {
// we are on a single post
include_once( "posts.php" );
}
}
So in your case specifically, I would suggest writing it as follows to get is_single
and is_admin
to work in functions.php
:
add_action( "wp", "include_conditionals" );
function include_conditionals() {
if( is_admin() ) {
require_once( "my-functions/admin-functions.php" );
} else if( is_single() ) {
require_once( "my-functions/single-functions.php" );
}
}
See here for more information.