簡體   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