Include files only if exists
-
Hi there,
I have found a code for display author-x.php in author.php if the file exists and using the current author ID.
if(! file_exists('author-'.$curauth->ID.'.php')) { include('author-'.$curauth->ID.'.php'); } else { //Default author page }
But that is for author.php file. I´m looking for a way to the same but in single.php pages and for categories, not only authors. Something like:
if(! file_exists('extra-'.author_ID.'.php')) { include('extra-'.author_ID.'.php'); } else { //anything else... }
I tried everything, just don´t know how to input the author ID or category ID into include code, so the filenames are generated. Can´t find anything about just simple include(‘file.php’).
Thanks for any help.
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Include files only if exists’ is closed to new replies.