Php Redux分类器-检索动态页面
我正在使用Redux Wordpress框架,在检索分类器中页面的数据时遇到了一些问题 这是我的数组,以“页面”作为数据,以及我的预设选项Php Redux分类器-检索动态页面,php,wordpress,redux-framework,Php,Wordpress,Redux Framework,我正在使用Redux Wordpress框架,在检索分类器中页面的数据时遇到了一些问题 这是我的数组,以“页面”作为数据,以及我的预设选项 array( 'id' => 'opt-homepage-layout', 'type' => 'sorter', 'title' => 'Layout Manager ',
array(
'id' => 'opt-homepage-layout',
'type' => 'sorter',
'title' => 'Layout Manager ',
'subtitle' => 'Organise how you want the layout on the home page',
'compiler' => 'true',
'data' => array('disabled' => 'pages'),
'options' => array(
'enabled' => array(
'hero' => 'Hero',
'menu' => 'Menu',
/*'team' => 'Team',
'quote' => 'Quote',
'portfolio' => 'Portfolio',
'testimonial' => 'Testimonial',
'prices' => 'Prices',*/
'map' => 'Map',
'contact' => 'Contact'
),
'disabled' => array(
),
'backup' => array(
),
),
'limits' => array(
'disabled' => 10,
'backup' => 20,
),
),
这是我为前端准备的,它可以很好地显示预定义的块,我无法让代码显示动态页面,到目前为止,我已经搜索了所有地方和所有死角
$layout = $redux_option['opt-homepage-layout']['enabled'];
if ($layout): foreach ($layout as $key=>$value) {
switch($key) {
case 'hero': get_template_part( 'templates/content', 'Hero' );
include(dirname(__FILE__) . '/../includes/hero.php');
break;
case 'menu': get_template_part( 'templates/content', 'Menu' );
include(dirname(__FILE__) . '/../includes/nav.php');
break;
case 'team': get_template_part( 'templates/content', 'Team' );
include(dirname(__FILE__) . '/../includes/team.php');
break;
case 'quote': get_template_part( 'templates/content', 'Quote' );
include(dirname(__FILE__) . '/../includes/quote.php');
break;
case 'portfolio': get_template_part( 'templates/content', 'Portfolio' );
include(dirname(__FILE__) . '/../includes/portfolio.php');
break;
case 'testimonial': get_template_part( 'templates/content', 'Testimonial' );
include(dirname(__FILE__) . '/../includes/testimonial.php');
break;
case 'prices': get_template_part( 'templates/content', 'Prices' );
include(dirname(__FILE__) . '/../includes/prices.php');
break;
case 'map': get_template_part( 'templates/content', 'Map' );
print_r ('<div id="map"></div>');
break;
case 'contact': get_template_part( 'templates/content', 'Contact' );
include(dirname(__FILE__) . '/../includes/contact.php');
break;
case 'pages': get_template_part( 'templates/content', 'Pages' );
include(dirname(__FILE__) . '/../includes/contact.php');
break;
}
}
endif;
$layout=$redux_选项['opt-homepage-layout']['enabled'];
if($layout):foreach($key=>$value的布局){
交换机($key){
案例“hero”:获取模板部分(“模板/内容”、“hero”);
include(dirname(_文件)'/../includes/hero.php');
打破
案例“菜单”:获取模板部分(“模板/内容”、“菜单”);
include(dirname(_文件)'/../includes/nav.php');
打破
案例“团队”:获取模板部分(“模板/内容”、“团队”);
include(dirname(_文件)'/../includes/team.php');
打破
案例“quote”:获取模板部分(“模板/内容”、“quote”);
include(dirname(_文件)'/../includes/quote.php');
打破
案例“公文包”:获取模板部分(“模板/内容”、“公文包”);
include(dirname(_文件)'/../includes/portfolio.php');
打破
案例“鉴定”:获取模板部分(“模板/内容”、“鉴定”);
include(dirname(_文件__)。'/../includes/testional.php');
打破
案例“价格”:获取模板部分(“模板/内容”、“价格”);
include(dirname(_文件)'/../includes/prices.php');
打破
案例“映射”:获取模板部分(“模板/内容”、“映射”);
印刷品(“”);
打破
案例“联系人”:获取模板部分(“模板/内容”、“联系人”);
include(dirname(_文件)'/../includes/contact.php');
打破
案例“页面”:获取模板部分(“模板/内容”、“页面”);
include(dirname(_文件)'/../includes/contact.php');
打破
}
}
endif;
你的帮助太好了 我使用以下命令显示(或隐藏)通过wp admin中的“opt homepage layout”字段选择的模板部分
<?php global $redux_option;
$layout = $redux_option['opt-homepage-layout']['enabled'];
if ($layout): foreach ($layout as $key=>$value) {
switch($key) {
case 'jumbotron': get_template_part( 'partials/home', 'jumbotron' );
break;
case 'jumbotron': get_template_part( 'partials/home', 'slides' );
break;
case 'overview': get_template_part( 'partials/home', 'overview' );
break;
case 'tickets': get_template_part( 'partials/home', 'tickets' );
break;
case 'history': get_template_part( 'partials/home', 'history' );
break;
case 'contact': get_template_part( 'partials/footer', 'contact' );
break;
}
}
endif; ?>
code-only答案不是很有用。你能解释为什么OP应该使用你的代码吗?我很高兴删除我的-1,如果你可以编辑你的文章。