alternative locations for templates

WordPress Event Management, Calendars & Registration Forums General Question alternative locations for templates

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 9 years, 8 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #12340

    http://wp-event-organiser.com/blog/tutorial/adding-alternative-locations-for-templates/

    Can anyone help me with the alternate template locations code ?

    add_filter( 'eventorganiser_template_stack', 'my_custom_events_template_directory' );
     function my_custom_events_template_directory( $template_stack ){
         array_unshift( $template_stack, plugin_dir_path**( __FILE__ )** );
         return $template_stack;
     }

    What should be entered at ( FILE ) ?

    I see this shown after the main code , do i replace the code above with this and an use an absolute path?

    add_filter( 'eventorganiser_template_stack', 'my_custom_events_template_directory' );
     function my_custom_events_template_directory( $template_stack ){
         array_unshift( $template_stack, 'absolute/path/to/directory/containing/templates/' );
         return $template_stack;
     }

    bit confused as it’s not working for me.

    andytc
    #12344

    Hi Andy,

    __FILE__ is magic constant which is the full path and filename of the current file. The plugin_dir_path() function just returns the parent directory of that path.

    So the second argument should be the absolute path (with a trailing slash) pointing to the desired directory. So assuming the absolute path is correct, then the above should work. You might want to add archive-event.php to that directory and check that file_exists( $absolutepath . 'archive-event.php' ) returns true.

    Stephen Harris
Viewing 2 posts - 1 through 2 (of 2 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.