wordpress 自定义_自定义帖子类型:将WordPress超越博客

wordpress 自定义

If you’ve used WordPress as a CMS for your clients, you’ve probably had to reassure a client that it’s not just ‘a blogging platform’. The Dashboard, however, doesn’t help. Unless you’ve installed plugins that provide custom post types, all an editor can add are posts and pages. Nearly every client site or premium theme I’ve built has needed something custom: products, events, testimonials, team members, services, locations, and so on.

如果您已经使用WordPress作为客户的CMS,则可能必须向客户保证,它不仅仅是“博客平台”。 但是,仪表板没有帮助。 除非您安装了提供自定义帖子类型的插件,否则编辑者只能添加帖子和页面。 我建立的几乎每个客户站点或高级主题都需要一些自定义的东西:产品,事件,推荐,团队成员,服务,位置等等。

There are some less-than-ideal ways to provide what your client needs. You can give them strict instructions for using post categories or parent pages to create faux post types (that’ll break as soon as they forget your instructions). You can find a plugin for each custom post type (that’ll introduce more code too, for you to vet and maintain). A cleaner solution is to add your own post types. This article will compare Types and Pods, two plugins for creating unique custom post types to match your (or your client’s) needs precisely.

有一些不理想的方法可以提供客户所需的东西。 您可以为他们提供关于使用帖子类别或父页面创建虚假帖子类型的严格说明(一旦他们忘记了说明,它们就会中断)。 您可以为每种自定义帖子类型找到一个插件(还将介绍更多代码,供您审核和维护)。 较干净的解决方案是添加您自己的帖子类型。 本文将比较TypesPods ,这两个插件用于创建独特的自定义帖子类型,以精确地满足您(或您的客户)的需求。

使用类型插件的自定义帖子类型 (Custom Post Types with the Types Plugin)

The Types plugin is a free plugin that provides a Dashboard admin area for creating custom post types, custom taxonomies, and custom fields for your WordPress site. It boasts over 100,000 commercial users and full WPML multilingual support. Types is part of the Toolset family of plugins: the other plugins (which are paid) allow you to create template views without code, generate new content from the front-end, and set up custom roles and access privileges. The free Types plugin provides a great deal of usefulness even without the other plugins.

Types插件是一个免费插件,提供了Dashboard管理区域,可为您的WordPress网站创建自定义帖子类型,自定义分类法和自定义字段。 它拥有超过100,000个商业用户和完整的WPML多语言支持。 类型是Toolset插件家族的一部分:其他插件(付费)允许您创建不带代码的模板视图,从前端生成新内容以及设置自定义角色和访问权限。 即使没有其他插件,免费的Types插件也提供了很多有用的功能。

The Types WordPress Plugin

使用类型插件的好处 (Benefits of Using the Types Plugin)

One of the biggest benefits to the Types plugin is its consistent, simple UI. Its design fits right into current Dashboard visual styling so it feels familiar right away. Types gives you all the options you need for configuring your own custom post type: you start by assigning it a title and a Dashboard icon.

Types插件的最大好处之一是其一致,简单的UI。 它的设计恰好适合当前的Dashboard视觉样式,因此立即感到熟悉。 类型为您提供了配置自己的自定义帖子类型所需的所有选项:首先为其分配标题和仪表板图标。

Once you’ve done that, you can configure many additional options about that post type: whether or not to give it an editor, custom fields, excerpt, a featured image, or several other common post meta-data options. The advanced configuration section allows users to make adjustments to the post type’s permalink structure, exclude its posts to appear in search results, permit exporting the post type, and allow the post type to be used in WordPress menus.

完成此操作后,您可以针对该帖子类型配置许多其他选项:是否为其提供编辑器,自定义字段,摘录,精选图片或其他几个常见的帖子元数据选项。 高级配置部分允许用户调整帖子类​​型的永久链接结构,排除其帖子显示在搜索结果中,允许导出帖子类型以及允许在WordPress菜单中使用帖子类型。

All of those features can be accessed in a single Dashboard admin page. Additionally, Types provides the ability to set custom taxonomies (categories, tags) and generate custom data fields (dates, URLs, file uploads).

所有这些功能都可以在一个仪表板管理页面中访问。 此外,类型还提供了设置自定义分类法(类别,标签)和生成自定义数据字段(日期,URL,文件上传)的功能。

All your Types settings can be exported and imported from one site to another. They can also be copied to an ’embedded-types’ directory in your theme, and synced via version control without even needing the plugin on the production site.

您所有的类型设置都可以从一个站点导出和导入到另一个站点。 也可以将它们复制到主题中的“嵌入式类型”目录中,并通过版本控制进行同步,而无需在生产站点上使用插件。

使用类型插件的缺点 (Drawbacks of Using the Types Plugin)

The only thing that I’d like to change about the Types plugin is its custom fields interface. That’s slightly off-topic for this post, but since custom post types and custom fields are often tightly related, I think it’s worth mentioning here. If you know you’re going to need a high degree of configurability for custom fields attached to your custom post types, keep reading to learn about the Pods plugin.

关于Types插件,我唯一要更改的是其自定义字段界面。 这对于这篇文章来说有点题外话,但是由于自定义帖子类型和自定义字段通常紧密相关,因此我认为在这里值得一提。 如果您知道需要对自定义帖子类型附加的自定义字段进行高度的配置,请继续阅读以了解Pods插件。

使用Pods插件自定义帖子类型 (Custom Post Types with the Pods Plugin)

The Pods plugin provides the same features that Types provides, but with a more complex interface and more advanced features. It’s also a free plugin with extensive documentation and a wide user base. Pods also offers several paid plugins to extend its free features, including search filters, CSV import, widget generation, and code-free templating.

Pods插件提供与Types相同的功能,但具有更复杂的界面和更高级的功能。 这也是一个免费的插件,包含大量文档和广泛的用户群。 Pods还提供了几个付费插件来扩展其免费功能,包括搜索过滤器,CSV导入,小部件生成和免代码模板。

The Pods WordPress Plugin

使用Pods插件的好处 (Benefits of Using the Pods Plugin)

In addition to the features that Types provides, Pods offers a more granular field-management system. After creating a new post type, Pods presents you with a blank slate, requiring you to add any necessary fields from scratch. The WordPress title and editor are enabled by default, but behind another screen (‘Advanced Options’).

除了Types提供的功能外,Pods还提供了更精细的字段管理系统。 创建新的帖子类型后,Pods会为您显示空白状态,要求您从头开始添加所有必要的字段。 默认情况下,WordPress标题和编辑器处于启用状态,但位于另一个屏幕(“高级选项”)后面。

Pods offers some additional custom field controls that Types lacks. These extra options include character limits, detailed date/time input, code syntax, and country/state lists.

Pods提供了Types缺少的一些其他自定义字段控件。 这些额外的选项包括字符限制,详细的日期/时间输入,代码语法和国家/州列表。

The Pods team has also included some very useful features besides custom post types: custom admin pages, extending comments, and building custom content types that live outside of the default WordPress database tables.

除自定义帖子类型外,Pods团队还包括一些非常有用的功能:自定义管理页面,扩展注释以及构建自定义内容类型(这些内容类型位于默认WordPress数据库表之外)。

使用Pod插件的缺点 (Drawbacks of Using the Pods Plugin)

The user interface is the largest drawback of the Pods plugin. Certain design details don’t match the standard WordPress Dashboard styling. This can make Pods feel like a different plugin. Not only does Pods look different, but the interface also requires more steps and more screens during the configuration process. This is probably a fair trade-off for power users: you’ll gain more control by doing more work.

用户界面是Pods插件的最大缺点。 某些设计细节与标准WordPress仪表板样式不匹配。 这可以使Pods感觉像是一个不同的插件。 Pod不仅外观不同,而且在配置过程中界面还需要更多步骤和更多屏幕。 对于高级用户来说,这可能是一个公平的权衡:通过做更多的工作,您将获得更多的控制权。

编写自己的自定义帖子类型代码 (Writing Your Own Custom Post Type Code)

Of course, WordPress developers often use core functions to build their own themes and plugins. If you want to keep all custom post type information in your own plugin or theme, you can use the register_post_type() function to write your own.

当然,WordPress开发人员经常使用核心功能来构建自己的主题和插件。 如果要将所有自定义帖子类型信息保留在自己的插件或主题中,则可以使用register_post_type() function编写自己的信息。

结论 (Conclusion)

Types and Pods both make it very easy for developers to extend WordPress’ CMS function and create a powerful, customized site management experience for clients. Types offers a clean interface with enough options to cover the vast majority of custom post type needs. Pods gives more configurability for advanced case uses at the cost of a slightly more cumbersome interface. For hard-core WordPress DIY-ers, register_post_type() provides the ability to roll your own custom post type code from scratch.

Types和Pod都使开发人员很容易扩展WordPress的CMS功能,并为客户创建强大的自定义站点管理体验。 类型提供了一个干净的界面,具有足够的选项来满足绝大多数自定义帖子类型的需求。 Pods为高级用例提供了更多的可配置性,但其接口却稍微麻烦一些。 对于WordPress核心DIY用户, register_post_type()可以从头开始滚动您自己的自定义帖子类型代码。

翻译自: https://www.sitepoint.com/custom-post-types-take-wordpress-beyond-blogging/

wordpress 自定义

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值