wpmetabox/mb-relationships
Composer 安装命令:
composer require wpmetabox/mb-relationships
包简介
A lightweight solution for creating many-to-many posts to posts relationships in WordPress.
关键字:
README 文档
README
MB Relationships helps you create many-to-many relationships between posts, pages or any custom post type. The plugin is lightweight and optimized for database and query performance.
The plugin allows you to create connections from posts to posts, posts to pages and so on. Then you can perform corresponding queries to retrieve posts that are connected to or from given posts.
Meta Box Lite
We recommend using Meta Box Lite, a feature-rich free UI version of Meta Box that provides UI and all free features for managing custom fields and dynamic content on WordPress, including post types, taxonomies, custom fields, and relationships.
It supports reciprocal and bi-directional relationships.
Why Do You Need Posts To Posts Relationships In WordPress?
Post relationships is a missing part in WordPress. The only "built-in" way that mimic the post relationship in WordPress is the post_parent for pages where you can create many child pages of a page (a one-to-many relationship). Unfortunately, that's available for pages and hierarchical post types only. Besides, it's not many-to-many relationship.
Below are some examples of posts to posts relationships that might help you see the benefit of this feature:
Creating Related Posts In WordPress
The simplest example is to manually create related posts in your WordPress website. When you edit a post, you can select posts that have similar or related content and display them in the frontend for further reading.
You can also query backward: displaying posts that link to the being read post as a reference to provide more information to your readers. With this, you don't need a WordPress related posts plugin anymore.
Example: Events And Bands
Suppose you have two custom post types, event and band, where:
- In each event there may be multiple bands, and
- Each band can participate in many events.
If people want to buy tickets, they could search for events in their location and see what bands are playing on a given date, or they could search for bands they like and see what date they are playing near their location.
In this example, we have created many-to-many relationships between events and bands.
Bi-directional relationships
MB Relationships allows you to create bi-directional connections. You will be able to query back and forth without any problem.
The data is stored in the database as a pair of (from_id, to_id), thus making it independent from either side.
Besides, for each side, there's a meta box that shows what are connected from/to. So you don't have to worry about the direction of the connection anymore.
An Alternative For The Posts 2 Posts Plugin (P2P Plugin)
MB Relationships is very much inspired by the popular plugin Posts 2 Posts which is not maintained anymore. We have taken the idea and made some improvements. The codebase and data structure is very similar.
Plugin features
- Simple APIs: the plugin provides simple APIs for registering relationships and retrieving connected items. It integrates with existing WordPress APIs such as
WP_Query,get_termsandget_users. See documentation for more information. - REST API: the plugin provides a REST API to manage relationships programatically. See documentation for more information.
- Uses custom relationship table to store relationships. That helps optimize the database storage and query performance.
- You can create relationships between any kind of content in WordPress: posts to posts, posts to users, etc. For posts to terms and posts to users, it's required the MB Term Meta and MB User Meta.
- Supports creating reciprocal relationships (posts-posts, users-users, ...).
- Supports creating bi-directional relationships and easily query them.
- Display connected items easily with shortcode.
- Extremely lightweight and fast.
Plugin Links
This plugin is a free extension of Meta Box plugin, which is a powerful, professional solution to create custom fields and custom meta boxes for WordPress websites. Using MB Relationships in combination with other extensions will help you manage any content types in WordPress easily and make your website more professional.
You might also like
If you like this plugin, you might also like our other WordPress products:
- Slim SEO - A fast, lightweight and full-featured SEO plugin for WordPress with minimal configuration.
- Falcon - A lightweight companion for making WordPress faster, cleaner, and more secure.
- GretaThemes - Free and premium WordPress themes that clean, simple and just work.
- Auto Listings - A car sale and dealership plugin for WordPress.
Installation
You need to install Meta Box plugin first
- Go to Plugins | Add New and search for Meta Box
- Click Install Now button to install the plugin
- After installing, click Activate Plugin to activate the plugin
Install MB Relationships extension
- Go to Plugins | Add New and search for MB Relationships
- Click Install Now button to install the plugin
- After installing, click Activate Plugin to activate the plugin
wpmetabox/mb-relationships 适用场景与选型建议
wpmetabox/mb-relationships 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.2k 次下载、GitHub Stars 达 29, 最近一次更新时间为 2018 年 07 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「ui」 「wordpress」 「Connection」 「Relationships」 「select2」 「relationship」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 wpmetabox/mb-relationships 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wpmetabox/mb-relationships 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 wpmetabox/mb-relationships 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Interface for Babel Street Text Analytics
Adds nested resources routing support along with related actions and relationship handlers to the Yii RESTful API framework
Adds KeyBy('id') to Eloquent relationships
Small service to parse database connection string into parts
Automatic auditing for Eloquent relationship changes (attach, detach, sync) using Laravel Auditing
Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for HiblaPHP
统计信息
- 总下载量: 1.2k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 29
- 点击次数: 27
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0
- 更新时间: 2018-07-24