dept-eduk/wordpress-toolkit

该软件包最新版本(2.0.0)没有提供许可证信息。

2.0.0 2019-10-31 10:16 UTC

This package is not auto-updated.

Last update: 2024-09-28 07:49:36 UTC


README

Models/Post.php

提供对文章类别和元/字段的访问。使用类属性缓存,因此对单个字段或属性的多次调用只会从数据库中查找一次值。

$post = new Post; // Optionally pass ID as constructor arg if not retrieving the current post

$id = $post->id;                                // 1
$title = $post->title;                          // Birthday Party
$authorName = $post->author;                    // Joan Evans
$permalink = $post->link;                       // https://whatever.com/my-birthday-party
$thumbnailUrl = $post->thumbnailUrl             // https://whatever.com/wp-content/uploads/my-birthday-party.jpg

$categories = $post->getTaxonomies('category'); // [0 => 'events', 1 => 'insights']

$acfFields['name'] = $post->field('name');      // field() retrieves meta and ACF fields
$acfFields['name'] = $post->field('doc.name');  // use dot notation to delve into ACF field groups, repeaters and arrays