WordPress:自定义帖子类型:使用自定义字段或分类法?

发布于 2024-09-11 08:29:11 字数 314 浏览 8 评论 0原文

我正在考虑使用 WP 自定义帖子类型来创建一个基本的房地产网站。

帖子类型将用于房产列表。我决定使用一种用于出售的帖子类型和一种用于出租的帖子类型,很简单,因为它们的房产信息有所不同。

典型的列表需要指定一些信息,即它是房屋、公寓还是只是一块土地。

使用自定义字段(元数据)与使用分类法(类别和标签)指定此信息有何优缺点?

我可以看到,基于分类法进行搜索很容易,但也可以查询自定义帖子类型元数据。

此外,这个问题似乎适用于任何需要离散选择的发布数据:元数据复选框、选择或分类法。

有什么想法吗?

谢谢。

I'm thinking about using WP custom post types to create a basic real estate website.

The post type will be for property listings. I've decided to have one post type for For Sale and one for Rentals, simple because they have somewhat different property information.

A typical listing will need to specify some information, ie, is it a house, an apartment or maybe it's just a piece of land.

What are the pros and cons of specifying this info using custom fields (meta data) versus using taxonomy (categories and tags)?

I can see that it's easy to search based on taxonomy, but custom post types meta data can also be queried.

Also, it seems that this question applies to any post data where discrete choices are required: meta data checkbox, select or taxonomy.

Any thoughts?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

杯别 2024-09-18 08:29:11

我对你想要做的事情的偏好是分类,原因如下:

SEO 和用户友好的 URL

使用类别和标签,WordPress 永久链接 设置为将该信息放入 URL 中。这将对您网站的 SEO 和可用性大有帮助,因为您将能够创建如下 URL:

http://yoursite.com/rentals
http://yoursite.com/for-sale/two-bedroom/123-fake-street

层次结构

我不知道您是否需要它,但构建一个层次结构类别很容易。这将为您在组织帖子时提供很大的灵活性。

主题编码

正如您所说,可以对元数据执行自定义查询,但 WordPress 有许多开箱即用的功能可以根据标签和类别进行查询和显示。这意味着您只需编写更少的代码即可让您的主题执行您想要的操作。

My preference for what you're trying to do would be taxonomy for the following reasons:

SEO and User Friendly URLs

With categories and tags, WordPress permalinks are setup to put that information in the URL for you. This will go a long way towards the SEO and usability of your site because you'll be able to create URLs like:

http://yoursite.com/rentals
http://yoursite.com/for-sale/two-bedroom/123-fake-street

Hierarchy

I don't know if you have the need for it, but building a hierarchy with categories is easy. This will give you lots of flexibility when it comes to organizing your posts.

Theme Coding

As you said, it's possible to perform custom queries for meta data, but WordPress has many out-of-the-box functions to query and display based on tags and categories. This will mean that you'll have to write less code to get your theme to do what you want.

我家小可爱 2024-09-18 08:29:11

我已经完全按照您所说的方式完成了,两种方式(使用自定义字段与类别)。我的观点是,您应该使用混合 - 使用类别来显示最重要的信息(例如待售、房产类型等),并使用自定义字段来显示列表的实际数据。

然后,Wordpress 有许多内置函数可以以非常直观的方式组织数据,并允许您轻松地将相同类型的属性分组在一起,这正是用户想要浏览数据的方式。

I've done exactly what you are talking about, both ways (using Custom Fields versus Categories). My view is you should use a mix - use Categories for the most important information (eg For Sale, Type of Property etc) and use Custom Fields for the actual data for the listing.

Wordpress then has many built in functions to organise that data in a really intuitive way, and allows you to easily group properties of the same type together, in exactly the way a user wants to browse the data.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文