定制 vincentts/wp-models 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

vincentts/wp-models

最新稳定版本:0.2

Composer 安装命令:

composer require vincentts/wp-models

包简介

Wrapper models around WP_Query

README 文档

README

Wrapper class around WP Query to create models.

Installations

Install the package through composer by running composer require "vincentts/wp-models".

Getting Started

Define model classes by extending PostModel or TermModel.

Post Model

namespace Models;

use Vincentts\WpModels\PostModel;

class Post extends PostModel {
    
    protected $post_type = 'post';
    
}

Term Model

namespace Models;

use Vincentts\WpModels\TermModel;

class Category extends TermModel {

    protected $taxonomy = 'category';
    
}

Defining relationships

namespace Models;

use Vincentts\WpModels\PostModel;
use Models\Category;

class Post extends PostModel {
    
    protected $post_type = 'post';

    public function categories() {
        return $this->has( Category::class );
    }

}

Usage

Getting posts with relationships

use Models\Post;

$posts = (new Post())->with(['categories'])->get();

Including meta data

Note ACF get_field will be used if it exists. Otherwise it will use get_post_meta.

use Models\Post;

$posts = (new Post())->meta(['summary', 'description'])->with(['categories'])->get();

There are also other methods similar to the arguments from WP_Query.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固