I am creating a plugin that needs to display external data, not wordpress posts.
What I have done: registered rewrites so wp recognizes my archive/single URLs, hooked into
template_include to direct it to use my template if the requested URL was one of mine, and then in the template I call a function to load the external data and display it in post/archive format.
This works fine as long as I dont switch templates. Unfotunately, there is a variation in twentyfourteen and twentyfifteen template structure, in which
#main are inverted.
body > #page > #content > #primary > #main
body > #page > #main > #primary > #content
This means that whatever one I code my plugin template for, it is broken in the other.
get_header(); ?> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <?php // Start the loop. while ( have_posts() ) : the_post();
get_header(); ?> <div id="primary" class="content-area"> <div id="content" class="site-content" role="main"> <?php // Start the Loop. while ( have_posts() ) : the_post();
So my question(s) are:
- Am I going about this the right way? Do you know of a better way to inject external data?
- Why are twentyfifteen tags inverted? Is this not a bug? Because I checked going back to twentlyeleven, and they are all in the order ...#main > #primary > #content.
- Is there a way to do this, without requiring including a template, so that it works on more sites? The templates are going to be problematic on each site the plugin is used on, for just such reasons. I would prefer to forgo including a template, and somehow hook into archive.php and single.php to display my content, given the URL matches one of my requests.