繁体   English   中英

如何在 wordpress 上设置分类类别作为我的页面?

[英]How can I set up a taxonomy category as my page on wordpress?

我的电子商务网站上有这个主题,它叫做 Soma。 他很棒,但遗憾的是,球队不再支持他了。

我的问题是如何将类别设置为页面? 因为在这个特别的主题上,侧边栏菜单不会出现在普通页面上,只会出现在商店页面和类别页面上。

我需要创建一个只显示一种产品类型的页面,使用 woocommerce 代码很容易。 但问题是在那个页面上,它没有显示侧边栏菜单。

我会在这里放一些打印件,也许它会有所帮助。

我是 php 的初学者,所以如果这是一个愚蠢的问题,我很抱歉,但我浏览了整个互联网,但没有找到任何相关内容。 打印问题

    <?php

/*
Default Template Page
*/

get_header();

if (have_posts()) : while (have_posts()) : the_post();

$soma_vc = preg_match("/\[vc_row.*?\]/i", get_the_content());

$soma_page_class = "container";

if ($soma_vc && function_exists('vc_map')) {
    $soma_page_class = "n-container";
}
?>
    <div class="<?php echo esc_attr($soma_page_class) ?>">
        <?php
            the_content();

            // WP Link Pages
            $args = array(
                'before' => '<div class="navigation">', 
                'after' => '</div>'
            );
            wp_link_pages($args);
        ?>
    </div>

<?php
endwhile; endif;

// Comments
comments_template();

get_footer();

这就是我需要放在那里的:

    <?php if($soma_shop_sidebar != '2' && is_active_sidebar('shop-sidebar')) : ?>
    <div class="soma-overlay" id="woo-sidebar_overlay"></div>
    <div class="woo-sidebar fixed-lateral left item-delay_off">
        <div class="hide-scrollbar">
            <div class="inner-hide_scrollbar">
                <div class="woo-sidebar_padding">
                    <a href="#" class="sidebar-close_button"><?php echo esc_html__('Close', 'soma') ?></a>
                    <?php get_sidebar('shop'); ?>
                </div>
            </div>
        </div>
    </div>

如果没有看到非开源的 Soma 的完整源代码,这仍然很难提供帮助。

但是,如果您只是需要自定义用于显示单个类别的模板,并且主题中还没有category.php模板,则过程如下:

1.为单个类别创建自定义模板

参考WordPress 模板层次结构,您需要创建一个名为category.php的自定义模板

如果您希望此页面的布局与另一个现有模板相似,只需将该模板的代码复制到category.php即可开始。

2. 将相关侧边栏代码复制到您的新类别中。php 模板

将您发布的侧边栏代码添加到新类别中。php 模板,无论它属于布局中的什么位置。

如果您不确定将其放在哪里,或者您想以与商店和类别页面相同的方式包含侧边栏模板:

  • 查看侧边栏当前出现的那些模板的代码
  • 找到他们包含侧边栏模板的地方
  • 在你的新category.php文件中做同样的事情

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM