barnythorpe/wp-fluent-queries 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

barnythorpe/wp-fluent-queries

最新稳定版本:0.1.0

Composer 安装命令:

composer require barnythorpe/wp-fluent-queries

包简介

A fluent interface for constructing Wordpress queries in a safe, readable and clean manner.

README 文档

README

Note

This package has been moved into: https://github.com/Barny-Thorpe/fluent-wp

Latest Version Passing Tests Packagist Licence Last Commit

This package aims to create a fluent interface for constructing Wordpress queries in a safe, readable and clean manner.

🔧 Installation

composer require barnythorpe/wp-fluent-queries

🛠 Usage

Main Query Builders

The package provides query builders for the following:

The queries are constructed like so:

$builder = new PostQueryBuilder();
$builder
    ->postType('custom_post_type')
    ->postsPerPage(12)
    ->fields('ids');

or to make life simpler using the factory class:

$query = Query::post()
    ->postType('custom_post_type')
    ->postsPerPage(12)
    ->fields('ids');

Nesting Conditions

The package also provides a solution for the complex nested queries within the main wordpress queries:

These can be constructed using the group and condition classes and added to the main query like so:

$wp_query = Query::post()
    ->postType('custom_post_type')
    ->taxQuery(QueryGroups::tax(
        QueryConditions::tax()->taxonomy('example_tax')->terms([1, 2, 3])->field('term_id'),
        QueryConditions::tax()->taxonomy('another_tax')->terms([4, 5, 6])->field('term_id'),
    ))
    ->metaQuery(QueryGroups::meta(
        QueryConditions::meta()->compare('=')->type('CHAR')->key('foo')->value('bar'),
        QueryConditions::meta()->compare('!=')->type('CHAR')->key('baz')->value('qux'),
    ));

Please go to the Groups and Conditions tests for more examples:

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-11