Php 如何在Wordpress中不重复某些重复的自定义字段
我将举一个例子来询问我计划用Wordpress做什么是否可行,以及最终如何做 [Wordpress网站] 完全通过自定义字段数据进行发布Php 如何在Wordpress中不重复某些重复的自定义字段,php,wordpress,Php,Wordpress,我将举一个例子来询问我计划用Wordpress做什么是否可行,以及最终如何做 [Wordpress网站] 完全通过自定义字段数据进行发布 Single post structure: - (A) Custom field artist name - (B) Custom field artist profil pic - (C) Custom field element description - (D) Custom field element image Post #1: - C
Single post structure:
- (A) Custom field artist name
- (B) Custom field artist profil pic
- (C) Custom field element description
- (D) Custom field element image
Post #1:
- Custom field artist name (John Cena)
- Custom field artist profil pic (johncena.jpg)
- Custom field element description (John Cena F-U to Hogan)
- Custom field element image (johncena_fu_hogan.jpg)
Post #2:
- Custom field artist name (John Cena)
- Custom field artist profil pic (johncena.jpg)
- Custom field element description (John Cena destroyed by Lesnar)
- Custom field element image (johncena_F5eved.jpg)
Post #3:
- Custom field artist name (John Cena)
- Custom field artist profil pic (johncena.jpg)
- Custom field element description (John Cena announces retirement)
- Custom field element image (johncena_retirement.jpg)
Post #4:
- Custom field artist name (Randy Orton)
- Custom field artist profil pic (randyorton.jpg)
- Custom field element description (Orton vs. Undertaker)
- Custom field element image (orton_vs_taker.jpg)
Post #5:
- Custom field artist name (Randy Orton)
- Custom field artist profil pic (randyorton.jpg)
- Custom field element description (Orton injured by Lesnar)
- Custom field element image (orton_injury_lesnar.jpg)
如您所见,关于某位艺术家的每一篇文章都有相同的前两个自定义字段,用作介绍。而剩下的2个总是不同的
现在我的问题是
有没有办法自定义搜索结果页面(自定义搜索、标签或特定类别列表调用的页面,通常为index.php)某个艺术家的所有帖子,只显示前两个自定义字段一次,其余两个字段显示所有当前帖子
例如:
url:mysite.com/tag/john-cena
Result:
- Custom field A
- Custom field B
- Custom field C
- Custom field D
- Custom field C
- Custom field D
- Custom field C
- Custom field D
通过插入特定变量(如“a和B=true,请勿重复”)在技术上可行吗?对于标签/类别页面,您可以使用以下内容获取查询对象的slug/名称,例如John Cena
$queryed_object=get_queryed_object();
变量转储($查询的对象)代码>
然后,您可以将其输入元查询,以收集所有以“艺术家名称”字段作为查询对象的帖子。但是,要使其起作用,您字段中输入的名称需要与标记/类别的名称相匹配
元查询信息可在此处找到:
希望这能给你指明正确的方向。你是说这样的$args=array('meta_value'=>'John Cena','meta_value'=>'johncena.jpg')$query=新的WP\u查询($args);更像$args=array('meta_value'=>'John Cena','meta_key'=>'field_name')$query=新的WP\u查询($args);其中字段\如果为艺术家名称创建的自定义字段的名称