英文:
Display specific content from a WordPress post
问题
我正在使用2022年的WordPress主题在我的网站上。我有许多属于类别A的帖子。我正在使用查询循环在页面上显示所有具有该类别的帖子。这部分工作正常。
从这里开始,我试图做的是只显示帖子内容中的特定信息。这些帖子本质上是一个包含许多段落的议程。
例如,一篇帖子可能如下所示:
- 开场:人员1
- 演讲者:某人
- 演讲者:某人
- 音乐:人们
- 演讲者:某人
- 结束:其他人
我不想在创建的页面上显示所有内容。我只想显示列出每个帖子演讲者的段落。
我尝试将数据放在一些HTML锚点中,但我看不到在我的查询循环中只显示特定锚点的方法。
是否有更好的方法来标记数据,以便稍后显示它?
感谢帮助。
英文:
I am using the twenty twenty-two WordPress theme on my site. I have many posts in category A. I am using a query loop on a page to display all of the posts with that category. This part works fine.
What I am trying to do from here is only display certain information within the content from the posts. The posts are essentially an agenda with many paragraphs.
For example a post might look like:
- Opening: Person 1
- Speaker: Somebody
- Speaker: Somebody
- Music: People
- Speaker: Somebody
- Closing: Someone else
I don't want to display all of the content on the page I am creating. I only want to show the paragraphs that list the speakers for each post.
I tried to place the data in some html anchors, but I don't see a way to only display specific anchors in my query loop.
Is there a better approach to tagging the data so I can show it later?
Appreciate the help.
答案1
得分: 0
你可以使用CSS来隐藏除了发言者段落之外的所有内容,但这并不理想。
更好的方法是创建一个自定义字段,其中包含有关发言者的段落,然后只在模板中显示该字段。像Advanced Custom Fields这样的插件可以使这个过程相对迅速和简便。
阅读这篇文章以开始使用ACF。
英文:
You could use CSS to hide everything except the paragraphs of speakers, but that's not ideal.
Better approach would be to have a custom field that has the paragraphs about speakers, and then display that field only in the template. Plugins like Advanced Custom Fields make this relatively quick and easy.
Read this article to get started with ACF.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论