0
我嘗試開發模板中包含文件的插件。這樣就在這時我的代碼視圖:Wordpress使用插件中的模板文件
/* Add a query var for template select, and and endpoint that sets that query var */
add_action('init', 'wpse22543_rewrite_system');
function wpse22543_rewrite_system() {
global $wp, $wp_rewrite;
$wp->add_query_var('template');
add_rewrite_endpoint('kalkulator_leasingowy', EP_ROOT);
$wp_rewrite->add_rule( '^/kalkulator_leasingowy/?$',
'index.php?template=kalkulator_leasingowy', 'bottom');
$wp_rewrite->flush_rules();
}
/* Handle template redirect according the template being queried. */
add_action('template_redirect', 'wpse22543_select_template');
function wpse22543_select_template() {
global $wp;
$template = $wp->query_vars;
if (array_key_exists('template', $template) &&
'kalkulator_leasingowy' == $template['template']) {
global $wp_query;
$wp_query->set('is_404', false);
include(get_stylesheet_directory().'/kalkulator_leasingowy.php');
exit;
}
}
function prefix_movie_rewrite_rule() {
add_rewrite_rule('kalkulator_leasingowy', 'index.php?template=kalkulator_leasingowy', 'top');
}
add_action('init', 'prefix_movie_rewrite_rule');
此代碼運行非常精細,包括模板文件,但我的模板(header.php文件和footer.php)默認使用一個可視化的作曲家,當我在使用此代碼頁面視圖這樣的:
視覺作曲家的作品好所有頁面上沒有/ kalkulator_leasingowy。 如何將VC包含到/ kalkulator_leasingowy中?
編輯
kalkulator_leasingowy.php
<?php
get_header();
?>
<div class="main-wrapper">
<div class="container ">
<div class="row">
</div>
</div>
</div>
<?php get_footer(); ?>
正如我理解的問題,由於模板正在使用,但輸出不是你所期望的,你的實際問題在於'kalkulator_leasingowy.php'文件,而不是你上面共享的模板代碼。在這種情況下,如果沒有看到模板文件代碼,很難評估爲什麼VC不能正確渲染 - 你能在這裏分享這些代碼嗎? –
Okey,我添加了這個文件。如果你可以請看看它,但是是一個非常簡單的文件。我不知道我可以添加header.php文件,因爲它在themeforest上購買了一個主題。問題很簡單,所有的主題文件都能正常工作,但我從我的插件中添加了「假/虛擬頁面」,並將kalkulator_leasingowy.php添加到主題文件,遺憾的是Visual composer在此頁面上不工作:( – bradley546994