0

晚上好,我已经设法在 WP 主题中嵌入了 redux 框架,一切都很好,但我更像是一个设计师而不是程序员,我想使用选项类型“sorter”(https://github.com/ ReduxFramework/redux-framework/wiki/Fields#sorter)根据启用的列和保存的顺序在主页中的“get_template_part”。

我的输出是 print_r($redux_options['home_blocks']['enabled']):

Array
(
    [placebo] => placebo
    [slider] => Slider
    [highlights] => Highlights
    [services] => Services
    [staticpage] => Static Page
)

我想要这样的东西:

slider = get_template_part('templates/content','slider');
highlights = get_template_part('templates/content','highlights');
services = get_template_part('templates/content','services');
staticpage = get_template_part('templates/content','staticpage');

当然具有与数组相同的顺序,并且如果存在于启用的列中。

我已经查看了 shoestrap3 以了解他们如何设法使分拣机看起来,但这个选项在最新版本(3.1.0.2)中没有使用

4

2 回答 2

3

尝试这个

global $redux_options;
$layout = $redux_options['home_blocks']['enabled'];

if ($layout): foreach ($layout as $key=>$value) {

    switch($key) {

        case 'slider': get_template_part( 'templates/content', 'slider' );
        break;

        case 'highlights': get_template_part( 'templates/content', 'highlights' );
        break;

        case 'services': get_template_part( 'templates/content', 'services' );
        break;

        case 'staticpage': get_template_part( 'templates/content', 'staticpage' );    
        break;  

    }

}

endif;
于 2014-03-15T12:19:21.390 回答
0

此处是 Redux 背后的首席开发人员。像这样的问题最好在我们的问题跟踪器上解决:https ://github.com/ReduxFramework/ReduxFramework/issues

但是,您的问题的答案在于我们的新文档站点:http ://docs.reduxframework.com/redux-framework/fields/sorter/

这将为您提供所需的东西。

如果你想更多地了解如何使用 Redux,我们明天将举办一个网络研讨会:https ://www2.gotomeeting.com/register/797085722

希望有帮助。

于 2014-03-15T05:49:04.843 回答