hz2新建Keyword頁面

新建一個single-keywords.php即可,需要篩選項再建taxonomy-knowledge-category.php
參考:https://www.tkwlkj.com/customize-wordpress-category-pages.html

WordPress中使用了ACF創建了自定義產品分類products,現在想實現自定義產品分類下的文章使用特定的詳情頁,不使用single.php,如何實現?要實現自定義產品分類下的文章使用特定的詳情頁而不使用single.php,您可以按照以下步驟操作:

創建自定義產品分類模板文件:
在您的主題文件夾中創建一個新的模板文件,命名為taxonomy-products.php。這里的products是您的自定義產品分類的標識符。
在這個模板文件中,您可以編寫您想要顯示的產品分類的內容和樣式。
在taxonomy-products.php中查詢文章:
使用WordPress提供的WP_Query或get_posts()函數在taxonomy-products.php中查詢特定分類下的文章。
您可以根據需要設置查詢參數,例如指定分類和數量等。
創建自定義文章模板文件:
創建一個單獨的文章模板文件,命名為single-products.php。這里的products是您的自定義產品文章類型的標識符。
在這個模板文件中,您可以編寫您想要顯示的單個產品文章的詳細內容和樣式。
鏈接到詳情頁:
確保在您的分類模板文件taxonomy-products.php中,每篇文章標題都鏈接到對應的詳情頁。
您可以使用WordPress提供的the_permalink()函數來獲取文章的鏈接。
保存并上傳文件:
保存您的模板文件并上傳到您的WordPress主題文件夾中。
通過這些步驟,您就可以實現自定義產品分類下的文章使用特定的詳情頁。確保您的主題支持這些自定義模板文件,并且在設置時備份您的文件以防萬一。

在ACF插件中如何查找自定義產品文章類型的標識符?
要找到自定義產品文章類型的標識符,您可以按照以下步驟在ACF(*自定義字段)插件中查找:

進入WordPress后臺:
登錄到您的WordPress網站的后臺管理頁面。
導航到ACF設置:
在WordPress后臺菜單中找到“自定義字段”(通常位于左側菜單中),然后單擊進入。
找到您的自定義字段組:
在自定義字段頁面中找到與您的自定義產品文章類型相關聯的自定義字段組。這可能是您之前創建的用于該文章類型的字段組。
編輯字段組:
單擊您的自定義產品文章類型相關聯的字段組。
查看字段設置:
在字段組編輯頁面中,您將看到與您的自定義產品文章類型相關的字段。
通常,您可以在字段設置中找到“位置”設置。在這里,您可以看到字段組與特定的文章類型相關聯。
查看相關文章類型:
在“位置”設置中,您將看到字段組與哪些文章類型相關聯。自定義產品文章類型的標識符將在這里列出。
通過這些步驟,您應該能夠在ACF插件中找到自定義產品文章類型的標識符。

ACF文章類型的標識符
不同類型的詳情頁

<!in single-keywords.php-->
<?php include( "header.php"); ?><!--內含主導航--><!--上大標題--><section class="SubPage-Hero" style="background-image: url(<?php echo get_template_directory_uri(); ?>/assets/images/inner-banner.jpg);">
<div class="container aos-init aos-animate" data-aos="fade-down"><h1><?php the_title(); ?></h1><ul><li><a href="<?php echo home_url(); ?>">Home</a></li><span><i class="fa fa-angle-right" aria-hidden="true"></i></span><?php if (is_singular('keywords')) : ?><?php// Get the terms associated with the product$terms = get_the_terms(get_the_ID(), 'keyword_category');if ($terms && !is_wp_error($terms)) :$term = array_shift($terms); // Get the first term?><li><a href="<?php echo get_term_link($term->term_id); ?>"><?php echo esc_html($term->name); ?></a></li><span><i class="fa fa-angle-right" aria-hidden="true"></i></span><?php endif; ?><li><?php the_title(); ?></li><?php elseif (is_post_type_archive('keyword')) : ?><li>Products</li><?php endif; ?></ul>
</div></section><!--edit by pp--><!--描述--><section class="shop-details"><div class="container"><div class="row"><!--<div class="main-tit-bar">--><!--                <h1 class="title"><?php the_title(); ?></h1>--><!--                <div class="clear"></div>--><!--            </div>--><article class="entry blog-article"><?phpif (have_posts()):while (have_posts()): the_post();the_content();endwhile;endif;?></article></div><!----><div class="lavelname"><h2>Related Products</h2></div><!--started Related Products--><div class="row"><?php// $current_category = get_queried_object();$current_category_name = get_post_meta($post->ID, '_product_size', true);$current_category = get_term_by('name',$current_category_name,'product_category');if ($current_category && !is_wp_error($current_category)) {$popular_tag = 'popular-products';  // Ensure we're querying for 'popular-products' tag$popular_args = array('post_type' => 'products', // Make sure you're querying 'products''posts_per_page' => 7,     // Limit to 5 products per query'orderby' => 'rand',       // Randomize the results on each page load'tax_query' => array('relation' => 'AND',array('taxonomy' => 'product_category', // Filter by product category'field'    => 'term_id','terms'    => $current_category->term_id,),array('taxonomy' => 'product_tag', // Filter by 'popular-products' tag'field'    => 'slug','terms'    => $popular_tag,),),);$popular_query = new WP_Query($popular_args);if ($popular_query->have_posts() && $popular_query->found_posts>7) :?><?php while ($popular_query->have_posts()) : $popular_query->the_post(); ?><div class="col-lg-4 col-sm-6"><div class="product_items"><div class="overflows"><div class="imagesec"><a href="<?php the_permalink(); ?>"><img  width="200" height="200" src="<?php the_post_thumbnail_url(); ?>" alt="<?php echo esc_attr(get_the_title() . ' - Product Image - ' . get_bloginfo('name')); ?>" title="<?php echo esc_attr(get_the_title()); ?>"></a><div class="overly"><div class="addto"><a href="<?php the_permalink(); ?>">View Detail</a></div></div></div><div class="comtevt"><p><?php the_title(); ?></p></div></div></div></div><?php endwhile; ?></div><?php elseif($popular_query->have_posts() && $popular_query->found_posts<=7) : $popular_args_again = array('post_type' => 'products', // Make sure you're querying 'products''posts_per_page' => 7,     // Limit to 5 products per query'orderby' => 'rand',       // Randomize the results on each page load'tax_query' => array('relation' => 'AND',array('taxonomy' => 'product_category', // Filter by product category'field'    => 'term_id','terms'    => $current_category->term_id,),),);$popular_query_again = new WP_Query($popular_args_again);if ($popular_query_again->have_posts() ) :?><?php while ($popular_query_again->have_posts()) : $popular_query_again->the_post(); ?><div class="col-lg-4 col-sm-6"><div class="product_items"><div class="overflows"><div class="imagesec"><a href="<?php the_permalink(); ?>"><img  width="200" height="200" src="<?php the_post_thumbnail_url(); ?>" alt="<?php echo esc_attr(get_the_title() . ' - Product Image - ' . get_bloginfo('name')); ?>" title="<?php echo esc_attr(get_the_title()); ?>"></a><div class="overly"><div class="addto"><a href="<?php the_permalink(); ?>">View Detail</a></div></div></div><div class="comtevt"><p><?php the_title(); ?></p></div></div></div></div><?php endwhile; ?></div><?php endif;else:echo '<p>No popular products found in this category.</p>';endif; wp_reset_postdata();} else {echo '<p>No product category found.</p>';}?><div class="image_sc"><?php if (has_post_thumbnail()) {the_post_thumbnail('full', ['style' => 'width:100%;']);} ?></div></div><!--end Related Products--><!----></div>
</section><!--開始第二節:熱門商品--><section class="shop-details"><div class="container"><!----><div class="lavelname"><h2>Top Selling Products</h2></div><!--started popular Products--><div class="row"><?php// $current_category = get_queried_object();$current_category_name = get_post_meta($post->ID, '_product_size', true);$current_category = get_term_by('name',$current_category_name,'product_category');if ($current_category && !is_wp_error($current_category)) {$popular_tag = 'popular-products';  // Ensure we're querying for 'popular-products' tag$popular_args = array('post_type' => 'products', // Make sure you're querying 'products''posts_per_page' => 6,     // Limit to 5 products per query'orderby' => 'rand',       // Randomize the results on each page load'tax_query' => array('relation' => 'AND',array('post_type' => 'products', // Ensure this matches your custom post type'posts_per_page' => 5, // Limit the number of products'orderby' => 'rand','order' => 'DESC',),),);$popular_query = new WP_Query($popular_args);if ($popular_query->have_posts()) :?><?php while ($popular_query->have_posts()) : $popular_query->the_post(); ?><div class="col-lg-4 col-sm-6"><div class="product_items"><div class="overflows"><div class="imagesec"><a href="<?php the_permalink(); ?>"><img  width="200" height="200" src="<?php the_post_thumbnail_url(); ?>" alt="<?php echo esc_attr(get_the_title() . ' - Product Image - ' . get_bloginfo('name')); ?>" title="<?php echo esc_attr(get_the_title()); ?>"></a><div class="overly"><div class="addto"><a href="<?php the_permalink(); ?>">View Detail</a></div></div></div><div class="comtevt"><p><?php the_title(); ?></p></div></div></div></div><?php endwhile; ?></div><?php endif; wp_reset_postdata();} else {echo '<p>No product category found.</p>';}?></div><!--end popular Products--><!----></div>
</section><!--結束第二節:熱門商品--><!--開始第三節:熱門搜索--><section class="shop-details"><div class="container"><!----><div class="lavelname"><h2>related search</h2></div><!--started popular Products--><div class="row"><?php// $current_category = get_queried_object();$current_category_name = get_post_meta($post->ID, '_product_size', true);$current_category = get_term_by('name',$current_category_name,'product_category');if ($current_category && !is_wp_error($current_category)) {$popular_tag = 'popular-products';  // Ensure we're querying for 'popular-products' tag$popular_args = array('post_type' => 'keywords', // Make sure you're querying 'products''posts_per_page' => 10,     // Limit to 5 products per query'orderby' => 'rand',       // Randomize the results on each page load'tax_query' => array('relation' => 'AND',array('post_type' => 'keywords', // Ensure this matches your custom post type'posts_per_page' => 10, // Limit the number of products'orderby' => 'rand','order' => 'DESC',),),);$popular_query = new WP_Query($popular_args);if ($popular_query->have_posts()) :?><?php while ($popular_query->have_posts()) : $popular_query->the_post(); ?><div class="col-lg-4 col-sm-6"><div class="product_items"><div class="overflows"><div class="imagesec"><a href="<?php the_permalink(); ?>"><img  width="200" height="200" src="<?php the_post_thumbnail_url(); ?>" alt="<?php echo esc_attr(get_the_title() . ' - Product Image - ' . get_bloginfo('name')); ?>" title="<?php echo esc_attr(get_the_title()); ?>"></a><div class="overly"><div class="addto"><a href="<?php the_permalink(); ?>">View Detail</a></div></div></div><div class="comtevt"><p><?php the_title(); ?></p></div></div></div></div><?php endwhile; ?></div><?php endif; wp_reset_postdata();} else {echo '<p>No product category found.</p>';}?></div><!--end popular Products--><!----></div>
</section><!--結束第san節:熱門搜索--><?php include( "footer.php"); ?>

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/79357.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/79357.shtml
英文地址,請注明出處:http://en.pswp.cn/web/79357.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

VRRP協議-IP地址冗余配置

有兩個服務器172.16.42.1和172.16.42.121&#xff0c;通過VRRP協議使兩臺設備共用一個虛擬地址172.16.42.100&#xff0c;當 172.16.42.1 可用時&#xff0c;它會作為主路由器使用虛擬 IP 地址&#xff1b;當它不可用時&#xff0c;172.16.42.121 會接管虛擬 IP 地址&#xff0…

21、DeepSeekMath論文筆記(GRPO)

DeepSeekMath論文筆記 0、研究背景與目標1、GRPO結構GRPO結構PPO知識點**1. PPO的網絡模型結構****2. GAE&#xff08;廣義優勢估計&#xff09;原理****1. 優勢函數的定義**2.GAE&#xff08;廣義優勢估計&#xff09; 2、關鍵技術與方法3、核心實驗結果4、結論與未來方向關鍵…

卡爾曼濾波算法(C語言)

此處感謝華南虎和互聯網的眾多大佬的無償分享。 入門常識 先簡單了解以下概念&#xff1a;疊加性&#xff0c;齊次性。 用大白話講&#xff0c;疊加性&#xff1a;多個輸入對輸出有影響。齊次性&#xff1a;輸入放大多少倍&#xff0c;輸出也跟著放大多少倍 卡爾曼濾波符合這…

SolidWork-2023 鼠標工程

地址 https://github.com/MartinxMax/SW2023-Project/tree/main/mouse 鼠標

vue 組件函數式調用實戰:以身份驗證彈窗為例

通常我們在 Vue 中使用組件&#xff0c;是像這樣在模板中寫標簽&#xff1a; <MyComponent :prop"value" event"handleEvent" />而函數式調用&#xff0c;則是讓我們像調用一個普通 JavaScript 函數一樣來使用這個組件&#xff0c;例如&#xff1a;…

Vite Proxy配置詳解:從入門到實戰應用

Vite Proxy配置詳解&#xff1a;從入門到實戰應用 一、什么是Proxy代理&#xff1f; Proxy&#xff08;代理&#xff09;是開發中常用的解決跨域問題的方案。Vite內置了基于http-proxy的代理功能&#xff0c;可以輕松配置API請求轉發。 二、基礎配置 在vite.config.js中配置…

圖像畫質算法記錄(前言)

一、背景介紹 本篇主要是對圖像畫質增強相關&#xff0c;進行簡單整理和記錄。 二、整體流程 整體效果主要受到兩部分影響&#xff1a; 1、前端isp處理。 2、后端畫質增強。 三、isp常規流程 可以參考&#xff1a;劉斯寧&#xff1a;Understanding ISP Pipeline 四、后端畫質…

Qt 中信號與槽(signal-slot)機制支持 多種連接方式(ConnectionType)

Qt 中信號與槽&#xff08;signal-slot&#xff09;機制支持 多種連接方式&#xff08;ConnectionType&#xff09; Qt 中信號與槽&#xff08;signal-slot&#xff09;機制支持 多種連接方式&#xff08;ConnectionType&#xff09;&#xff0c;用于控制信號發出后如何調用槽…

卷積神經網絡實戰(4)代碼詳解

目錄 一、導包 二、數據準備 1.數據集 2. 標準化轉換(Normalize) 3.設置dataloader 三、定義模型 四、可視化計算圖&#xff08;不重要&#xff09; 五、評估函數 六、Tensorboard 一、導包 import matplotlib as mpl import matplotlib.pyplot as plt %matplotlib i…

深入解析進程地址空間:從虛擬到物理的奇妙之旅

深入解析進程地址空間&#xff1a;從虛擬到物理的奇妙之旅 前言 各位小伙伴&#xff0c;還記得我們之前探討的 fork 函數嗎&#xff1f;當它返回兩次時&#xff0c;父子進程中同名變量卻擁有不同值的現象&#xff0c;曾讓我們驚嘆于進程獨立性與寫時拷貝的精妙設計。但你是否…

opencv處理圖像(二)

接下來進入到程序線程設計部分 我們主線程負責圖形渲染等操作&#xff0c;OpenGL的限制&#xff0c;opencv技術對傳入圖像加以處理&#xff0c;輸出預期圖像給主線程 QThread 我之前也是在想給opencv開一個專門的線程&#xff0c;但經過了解有幾個弊端&#xff0c;第一資源浪…

學習threejs,使用Physijs物理引擎

&#x1f468;??? 主頁&#xff1a; gis分享者 &#x1f468;??? 感謝各位大佬 點贊&#x1f44d; 收藏? 留言&#x1f4dd; 加關注?! &#x1f468;??? 收錄于專欄&#xff1a;threejs gis工程師 文章目錄 一、&#x1f340;前言1.1 ??Physijs 物理引擎1.1.1 ??…

ARCGIS PRO DSK 選擇坐標系控件(CoordinateSystemsControl )的調用

在WPF窗體上使用 xml&#xff1a;加入空間命名引用 xmlns:mapping"clr-namespace:ArcGIS.Desktop.Mapping.Controls;assemblyArcGIS.Desktop.Mapping" 在控件區域加入&#xff1a; <mapping:CoordinateSystemsControl x:Name"CoordinateSystemsControl&q…

LangGraph(三)——添加記憶

目錄 1. 創建MemorySaver檢查指針2. 構建并編譯Graph3. 與聊天機器人互動4. 問一個后續問題5. 檢查State參考 1. 創建MemorySaver檢查指針 創建MemorySaver檢查指針&#xff1a; from langgraph.checkpoint.memory import MemorySavermemory MemorySaver()這是位于內存中的檢…

深入理解Mysql

BufferPool和Changebuffer是如何加快讀寫速度的? BufferPool 在Mysql啟動的時候 Mysql會申請連續的空間來存儲BufferPool 每個頁16kb 當控制塊不足以存儲信息的時候就會向后申請一個新的頁 每個控制塊都對應了一個緩存頁 控制塊占chunk的百分之5左右 LRU鏈表 Changebuffer …

Python核心編程深度解析:作用域、遞歸與匿名函數的工程實踐

引言 Python作為現代編程語言的代表&#xff0c;其作用域管理、遞歸算法和匿名函數機制是構建高質量代碼的核心要素。本文基于Python 3.11環境&#xff0c;結合工業級開發實踐&#xff0c;深入探討變量作用域的內在邏輯、遞歸算法的優化策略以及匿名函數的高效應用&#xff0c…

《用MATLAB玩轉游戲開發》貪吃蛇的百變玩法:從命令行到AI對戰

《用MATLAB玩轉游戲開發&#xff1a;從零開始打造你的數字樂園》基礎篇&#xff08;2D圖形交互&#xff09;-&#x1f40d; 貪吃蛇的百變玩法&#xff1a;從命令行到AI對戰 &#x1f3ae; 歡迎來到這篇MATLAB貪吃蛇編程全攻略&#xff01;本文將帶你從零開始&#xff0c;一步步…

Android平臺FFmpeg音視頻開發深度指南

一、FFmpeg在Android開發中的核心價值 FFmpeg作為業界領先的多媒體處理框架&#xff0c;在Android音視頻開發中扮演著至關重要的角色。它提供了&#xff1a; 跨平臺支持&#xff1a;統一的API處理各種音視頻格式完整功能鏈&#xff1a;從解碼、編碼到濾鏡處理的全套解決方案靈…

AI大模型驅動的智能座艙研發體系重構

隨著AI大模型&#xff08;如LLM、多模態模型&#xff09;的快速發展&#xff0c;傳統智能座艙研發流程面臨巨大挑戰。傳統座艙研發以需求驅動、功能固定、架構封閉為特點&#xff0c;而AI大模型的引入使得座艙系統向自主決策、動態適應、持續進化的方向發展。 因此思考并提出一…

Day20 常見降維算法分析

一、常見的降維算法 LDA線性判別PCA主成分分析t-sne降維 二、降維算法原理 2.1 LDA 線性判別 原理 &#xff1a;LDA&#xff08;Linear Discriminant Analysis&#xff09;線性判別分析是一種有監督的降維方法。它的目標是找到一個投影方向&#xff0c;使得不同類別的數據在…