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.mzph.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;使得不同类别的数据在…