WordPress.org

Ready to get started?Download WordPress

Ideas

locate_template should also look into the plugin directory

  1. lerizzle
    Member

    It would be nice if locate_template() would look last in the plugin directory for templates to load if it didn't find it in the other 2 spots.

    Posted: 2 years ago #
  2. Stefan Matei
    Member

    12345

    Yes, that would be great!

    I was currently looking for a workaround myself.

    Posted: 2 years ago #
  3. Hal Gatewood
    Member

    Here is my current structure:

    // LOOK FOR TEMPLATE IN THEME
    $template = locate_template( array( "loop-article-slug.php", "loop-article.php" ) );

    // LOOK IN PLUGIN
    if( !$template )
    {
    $template = dirname(__FILE__) . "/loop-article.php";
    }

    // LOAD TEMPLATE
    if( $template )
    {
    include( $template );
    }

    Posted: 8 months ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    4 Votes
  • Status

    This idea is under consideration