简体   繁体   English

如何将永久链接存储到用户在他的元数据中发布的帖子-WordPress

[英]How to Store Permalink to Post Authored by User in His Meta Data - WordPress

Here is the situation. 这是情况。

I have a custom post type, let's call it "Listings." 我有一个自定义帖子类型,我们称其为“列表”。 I have numerous authors, each of whom has exactly one post of type "Listings." 我有很多作者,每位作者只有一个职位属于“列表”类型。 No more, no less. 不多不少。

I want a custom field, let's call it "listing_link", where the link to each author's "Listings" post is stored. 我想要一个自定义字段,我们将其称为“ listing_link”,其中存储了每个作者的“ Listings”帖子的链接。 I would like this to be generated automatically. 我希望这是自动生成的。

So essentially I need some kind of function that will: 所以本质上我需要某种功能,它将:

1. Cycle through each author 1.循环浏览每位作者

2. Find all posts of type "Listings" by that author 2.查找该作者的“列表”类型的所有帖子

3. Get the permalink to the first (and only) post of that type by that author 3.获得该作者在该类型的第一(也是唯一)帖子上的永久链接

4. Finally save that link in a custom field I've created 4.最后,将该链接保存在我创建的自定义字段中

I could code bits of this, but I'm really not sure where to start. 我可以对此进行编码,但是我真的不确定从哪里开始。 When/how would this function run? 此功能何时/如何运行? How would it refresh? 如何刷新? How do you actually save it to their meta data? 您实际上如何将其保存到他们的元数据?

Any help would be appreciated, even if it's not a full script. 任何帮助将不胜感激,即使它不是完整的脚本。 I really just need to be sent in the right direction! 我真的只需要按正确的方向发送! If I can come up with a functioning solution, I will share it with the community! 如果我能提出一个可行的解决方案,我将与社区分享!

Do you have to store 'listing-link'? 您是否必须存储“ listing-link”? Why not just query "listings" when you need the information? 为什么不只在需要信息时查询“清单”?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM