I'm running some functions that will allow a user to register their own custom templates to my custom theme from an external directory. They can see these page templates in the wp-adminwp-admin
and they render on the frontend.
Everything works fine with this, but I would like to register files from multiple directories, not just one directory.
I need to make $file$file
equal multiple directories. I've tried an arrayarray. I've tried &&&&
and a couple other things, including the below code, but nothing works.
I'm not a pro, but what am I missing here? Can this be done? In the code below I see that the last $file =$file =
takes priority over the previous $file =$file =
.
So is there a way I can make $file$file
equals multiple paths?
In short, I want $file$file
to consider multiple paths.
The code probably explains itself what I am trying to achieve.
$file = CUSTOM_OPTION_BACKEND_TEMPLATES_PATH . '/home/' . get_post_meta( $post->ID, '_wp_page_template', true );
$file = CUSTOM_OPTION_BACKEND_TEMPLATES_PATH . '/pages/' . get_post_meta( $post->ID, '_wp_page_template', true );
$file = CUSTOM_OPTION_BACKEND_TEMPLATES_PATH . '/blog/' . get_post_meta( $post->ID, '_wp_page_template', true );
$file = CUSTOM_OPTION_BACKEND_TEMPLATES_PATH . '/single-posts/' . get_post_meta( $post->ID, '_wp_page_template', true );
$file = CUSTOM_OPTION_BACKEND_TEMPLATES_PATH . '/products/' . get_post_meta( $post->ID, '_wp_page_template', true );
$file = CUSTOM_OPTION_BACKEND_TEMPLATES_PATH . '/templates/' . get_post_meta( $post->ID, '_wp_page_template', true );
$file = CUSTOM_OPTION_BACKEND_TEMPLATES_PATH . '/products/' . get_post_meta( $post->ID, '_wp_page_template', true );
if ( file_exists( $file ) ) {
return $file;
}