我正在创建一个插件,它需要显示外部数据,而不是wordpress帖子。
我所做的:注册重写,以便wp识别我的存档/单个URL,连接到template_include
如果请求的URL是我的URL,则指示它使用我的模板,然后在模板中调用一个函数来加载外部数据并以后期/归档格式显示。
只要我不切换模板,这就行了。不幸的是,在第214和215个模板结构中有一个变化,其中#content
和#main
是倒置的。
二十点十五分:body > #page > #content > #primary > #main
body > #page > #main > #primary > #content
twentyfifteen/single.php
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();
twentyfourteen/single.php
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();
因此,我的问题是:我这样做对吗?您知道注入外部数据的更好方法吗\\\\主>\\\\内容