最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

theme development - Add extra elements to the_post in a custom post_type

programmeradmin0浏览0评论

I managed to create a custom post type (I called it stores) to work in the loop, I plan to create a template with bootstrap to have all the stores the same design and have the capacity to modify all of them with the editor...

What I need is a way to add extra elements to the_post (elements like the_title, the_content or the_time, but custom made, like "the_type" or "the_storetype", etc)

I managed to create a custom post type (I called it stores) to work in the loop, I plan to create a template with bootstrap to have all the stores the same design and have the capacity to modify all of them with the editor...

What I need is a way to add extra elements to the_post (elements like the_title, the_content or the_time, but custom made, like "the_type" or "the_storetype", etc)

Share Improve this question asked Feb 19, 2020 at 17:36 Cheo MolinaCheo Molina 155 bronze badges 3
  • You can add either custom taxonomies or postmeta. It really depends on how you want to use the data. If you ever want to be able to query for posts that have a certain piece of data, you'll want to set it up as custom taxonomies, as taxonomy queries are much more performant than meta queries. Once you add the data, you will also need to set up or update your theme template to display it however you like. – WebElaine Commented Feb 19, 2020 at 17:39
  • the_post() is not a template tag. It's not something that produces output that you can add it. It's used for setting up the query properly in your template so that you can output stuff. The things you're describing need to be added to the template. – Jacob Peattie Commented Feb 19, 2020 at 23:39
  • But my goal is to repeat certain parameters like $storeName or $OpeningHours to all stores in the site, and it's extremely unconvenient to do it 1 by 1... I want something like Woocommerce that you only fill some data and it automatically creates a page with all the data arranged inside of it – Cheo Molina Commented Feb 20, 2020 at 7:46
Add a comment  | 

1 Answer 1

Reset to default 0

-RESOLVED

I was able to do it by copying the template functions that wordpress gives and modifying them to fetch what I needed to in the DB instead of what they were supposed to get.

发布评论

评论列表(0)

  1. 暂无评论