【问题标题】:Remove Sidebar Woo Commerce in Roots WP Theme删除 Roots WP 主题中的侧边栏 Woo Commerce
【发布时间】:2013-12-18 19:51:07
【问题描述】:

我正在使用 Roots WP 主题。无论如何,我也安装了 Woo Commerce,我正在尝试将其配置为不在所有 Woo Commerce 页面上显示任何侧边栏。

整个教程我已经完成了两次:http://roots.io/using-woocommerce-with-roots/

它没有解决如何删除 Roots/WooCommerce 的侧边栏,只是如何删除重复的页眉、页脚和侧边栏。查看!我做到了;现在我只想一起删除侧边栏。

我已将archive-product.php、single-product.php页面添加到Roots主题中,并插入了这行代码:

 <?php woocommerce_content(); ?>

我已编辑 lib/config.php 文件以不显示某些主题的侧边栏。

 array(
        'template-custom.php',
        'template-page.php',
        'template-shop.php',
        'archive-product.php',
        'single-product.php'
    )

没用!

我已尽我所能移除侧边栏。有人有什么建议吗?

谢谢!

【问题讨论】:

    标签: wordpress wordpress-theming woocommerce


    【解决方案1】:

    您可以将任何WooCommerce conditionals 添加到/lib/config.php 的侧边栏配置中的第一个数组中。

    我将首先添加 is_woocommerce 以从所有 WooCommerce 页面中删除侧边栏。

    示例:

    function roots_display_sidebar() {
      $sidebar_config = new Roots_Sidebar(
        /**
         * Conditional tag checks (http://codex.wordpress.org/Conditional_Tags)
         * Any of these conditional tags that return true won't show the sidebar
         *
         * To use a function that accepts arguments, use the following format:
         *
         * array('function_name', array('arg1', 'arg2'))
         *
         * The second element must be an array even if there's only 1 argument.
         */
        array(
          'is_404',
          'is_front_page',
          'is_woocommerce' // New Conditional for WooCommerce Pages
        ),
        /**
         * Page template checks (via is_page_template())
         * Any of these page templates that return true won't show the sidebar
         */
        array(
          'template-custom.php'
        )
      );
    

    【讨论】:

    • 非常欢迎,请随时加入我们的Roots Discourse 以了解 Roots 的具体问题!
    • 我正在使用多站点、root 主题和 woocommerce。我还使用了 Chris 在roots.io 上写的模板覆盖。这个明显的解决方案对我不起作用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-24
    • 2019-02-09
    • 1970-01-01
    • 2013-12-13
    • 1970-01-01
    相关资源
    最近更新 更多