0

wordpress テーマで redux フレームワークを使用しています。

私のグローバル変数は$ua_options

だから私は私の中にスイッチを作成しましたconfig.php

array(
   'id'       => 'ua-enable-responsive',
   'type'     => 'switch',
   'title'    => __( 'Responsive', 'redux-framework-demo' ),
   'compiler' => 'true',
   'mode'     => false,
),

functions.phpは条件付きでファイルをキューに入れたい:

if ($ua_options['ua-enable-responsive']) {
    wp_enqueue_style( 'mytheme-bootstrap', get_template_directory_uri() . '/css/bootstrap.css'      );
}
else {
    wp_enqueue_style( 'mytheme-non-responsive', get_template_directory_uri() . '/css/no-responsive.css' );      
}

しかし、それはうまくいかないようです。no-responsive.cssバックエンドでスイッチをオンにしても、2 番目のファイルは常に読み込まれます。

私はまた、私のトップでグローバル変数を呼び出しましたfunctions.php

global $ua_options;

なぜこれがうまくいかないのか、誰かがアイデアを持っていますか? また、そのようなエラー/警告を表示する方法はありますか?

4

4 に答える 4

0

これを header.php で試してください。これも修正

    if ($ua_options['ua-enable-responsive'] == '1') {
// '1' true and '0' false .
        wp_enqueue_style( 'mytheme-bootstrap', get_template_directory_uri() . '/css/bootstrap.css'      );
    }
    else {
        wp_enqueue_style( 'mytheme-non-responsive', get_template_directory_uri() . '/css/no-responsive.css' );      
    }
于 2015-02-16T19:48:09.523 に答える