[英]How can i get all post of taxonomy category post by taxonomy category id or taxonomy category name in 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
模板,則過程如下:
參考WordPress 模板層次結構,您需要創建一個名為category.php
的自定義模板
如果您希望此頁面的布局與另一個現有模板相似,只需將該模板的代碼復制到category.php
即可開始。
將您發布的側邊欄代碼添加到新類別中。php 模板,無論它屬於布局中的什么位置。
如果您不確定將其放在哪里,或者您想以與商店和類別頁面相同的方式包含側邊欄模板:
category.php
文件中做同樣的事情
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.