简体   繁体   English

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

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

I have this theme on my ecommerce website and its called Soma.我的电子商务网站上有这个主题,它叫做 Soma。 He is great but sadly, the team doesn't support anymore.他很棒,但遗憾的是,球队不再支持他了。

The question I have is how can I set up a category as a page?我的问题是如何将类别设置为页面? Cause on this particularly theme, the sidebar menu doesn't show up on normal pages, just on shop pages and categories pages.因为在这个特别的主题上,侧边栏菜单不会出现在普通页面上,只会出现在商店页面和类别页面上。

I need to create a page that shows only one type of product, that's ease with woocommerce code.我需要创建一个只显示一种产品类型的页面,使用 woocommerce 代码很容易。 But the problem is that on that page, it doesn't show the sidebar menu.但问题是在那个页面上,它没有显示侧边栏菜单。

I will put some prints here, maybe it can help.我会在这里放一些打印件,也许它会有所帮助。

I'm a beginner on php so I'm sorry if this is a dumb question but I looked all over the internet and I didn't find anything related.我是 php 的初学者,所以如果这是一个愚蠢的问题,我很抱歉,但我浏览了整个互联网,但没有找到任何相关内容。 print of the problem打印问题

    <?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();

And this is what I need to put there:这就是我需要放在那里的:

    <?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>

This is one is still tough to assist on without seeing the full source of Soma, which isn't open-source.如果没有看到非开源的 Soma 的完整源代码,这仍然很难提供帮助。

However, if you simply need to customize the template used to display a single category, and there isn't a category.php template in the theme yet, this is the procedure:但是,如果您只是需要自定义用于显示单个类别的模板,并且主题中还没有category.php模板,则过程如下:

1. Create a custom template for single categories 1.为单个类别创建自定义模板

Referring to the WordPress Template Hierarchy , you'll want to create a custom template called category.php参考WordPress 模板层次结构,您需要创建一个名为category.php的自定义模板

If you want the layout for this page to be similar to another existing template, simply copy that template's code into category.php to begin.如果您希望此页面的布局与另一个现有模板相似,只需将该模板的代码复制到category.php即可开始。

2. Copy relevant sidebar code into your new category.php template 2. 将相关侧边栏代码复制到您的新类别中。php 模板

Add the sidebar code you've posted into your new category.php template, wherever it belongs in the layout.将您发布的侧边栏代码添加到新类别中。php 模板,无论它属于布局中的什么位置。

If you're not sure where to put it, or you'd like to include a sidebar template in the same way that the Shop and Categories pages do:如果您不确定将其放在哪里,或者您想以与商店和类别页面相同的方式包含侧边栏模板:

  • look at code of those templates where the sidebar does currently appear查看侧边栏当前出现的那些模板的代码
  • find the place where they include the sidebar template找到他们包含侧边栏模板的地方
  • do the same thing in your new category.php file在你的新category.php文件中做同样的事情

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

相关问题 如何在wordPress中按分类法类别ID或分类法类别名称获取所有分类法类别的帖子? - How can i get all post of taxonomy category post by taxonomy category id or taxonomy category name in wordPress? 如何在WordPress查询中获取分类法类别的所有记录? - How can I get all records of taxonomy category in WordPress Query? WordPress,分类页面未链接 - WordPress, taxonomy page not linking up 高级自定义字段在类别页面上显示不正确。 我如何只限于分类页面? - Advanced custom fields displaying incorrectly on category pages. How do i limit to my taxonomy page only? 如何根据页面类别在wordpress中显示帖子? - How can I display posts in wordpress based on page category? 如何从Wordpress主页中排除特定类别? - How can I exclude a particular category from my Wordpress homepage? 如何在Wordpress中设置类别标题的样式? - How can I style my Category Heading in Wordpress? 我可以在WordPress自定义页面中设置会话吗 - Can I set up a session in a WordPress custom page 如何从Wordpress类别/存档页面中提取内容并将其设置为子域的索引? - How to pull content from a Wordpress Category/Archive page and set it up as the index of a subdomain? 如何创建自定义分类法,我可以为该特定分类法创建 select 类别 - How to create custom taxonomy where I can select category for that particular taxonomy
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM