Class: \Conifer\Post\Post (abstract)

High-level behavior for WP Posts, on top of TimberPost class

Visibility Function
public static add_admin_column(string $key, string $label, \callable $getValue=null)</strong> : void
Add a custom column to the admin for the given post type, with content provided through a callback. display in the custom column for. If not given, the column will display the value of the meta field whose meta_key is equal to $key. a given post. Takes a post ID as its sole parameter.
public static add_admin_filter(\string $name, array $options=array(), \callable $queryModifier=null)</strong> : void
Add a custom filter to the admin for the given post type, with custom query behavior provided through a callback. Optional for defining taxonomy filters. If $name is a taxonomy, $options defaults to all non-empty terms in the taxonomy, plus an "Any $name" option. at query time. Callback params: WP_Query $query the query being executed string $value the filter value selected by the admin user The $queryModifier param is optional for cases such as querying by taxonomy term, in which case WP adds the term to the query automatically.
public static add_taxonomy_admin_filter(\string $tax)</strong> : void
Add a custom admin filter for a taxonomy.
public static configure_advanced_search(array $config)</strong> : void
public static create(array $data)</strong> : \Project\Post
Create a new post from an array of data tables. The following keys are special, and their corresponding values will end up in the wp_posts table: post_author post_date post_date_gmt post_content post_content_filtered post_title post_excerpt post_status comment_status ping_status post_password post_name to_ping pinged post_modified post_modified_gmt post_parent menu_order post_mime_type guid post_category tags_input tax_input The keys "ID" and "post_type" are blacklisted and will be ignored. The value for "ID" is generated on post creation by WordPress/MySQL; The value for "post_type" will always come from $this->get_post_type(). All others key/value pairs are considered metadata and end up in wp_postmeta.
public static exists(int $id)</strong> : boolean true if the post exists, false otherwise
Check whether a post by the given ID exists
public static get_all(array/array/string/array $query=array())</strong> : array an array of all matching post objects
Get all the posts matching the given query (defaults to the current/global WP query constraints)
public static get_all_grouped_by_term(\string $taxonomy, array $terms=array(), array $postQueryArgs=array())</strong> : array an array like: php [ [ 'term' => { Category 1 WP_Term object }, 'posts' => [...], [ 'term' => { Category 2 WP_Term object }, 'posts' => [...], ]
Get all published posts of this type, grouped by terms of $taxonomy e.g. "category" in the array can be any of the following: a term ID (int or numeric string) a term slug (string) a WP_Term object a Timber\Term object Defaults to all terms within $taxonomy. array passed to get_all(). Defaults to an empty array.
public static get_blog_url() : string the URL
Get the URL of the blog landing page (what WP calls the "post archive" page)
public get_related_by_category(\integer $postCount=3)</strong> : Post[] an array of Post objects
Get related Posts of the same post type, who share categories with this Post.
public get_related_by_tag(\integer $postCount=3)</strong> : Post[] an array of Post objects
Get related Posts of the same post type, who share tags with this Post.
public get_related_by_taxonomy(\string $taxonomy, \integer $postCount=3)</strong> : Post[] an array of Post objects
Get related Posts of the same post type, who share terms in $taxonomy with this Post.
public static latest(\integer $count=3)</strong> : void
Get the latest posts
public static register_taxonomy(\string $name, array $options=array(), \boolean $omitPostType=false)</strong> : void
Register a taxonomy for this post type
public static register_type() : void
Register this post type given the high-level label options.
public type() : void
Place tighter restrictions on post types than Timber, forcing all concrete subclasses to implement this method.
public static type_options() : array
Default implementation of custom post type labels, for use in register_post_type().
protected static _post_type() : string
Child classes must declare their own post types
protected static allow_custom_filtering() : void
Whether to show the custom filter on the edit screen for the given post type.
protected static get_taxonomy_label(\string $tax)</strong> : string the singular label
Get the singular_name label for a taxonomy
protected static querying_by_custom_filter(\string $name, \WP_Query $query)</strong> : void
Whether the user is currently trying to query by the custom filter, according to GET params and the current post type; determines whether the current WP_Query needs to be modified. name attribute
protected static render_custom_filter_select(array $data)</strong> : void
Render the
Examples of Post::register_taxonomy()
```php
  Post::register_taxonomy('sign', [
'plural_label' => 'Signs',
'labels' => [
  'add_new_item' => 'Divine New Sign'
]
  ]);
// equivalent to:
  register_taxonomy('sign', 'person', [
'labels' => [
  'name'          => 'Signs',
  'singular_name' => 'Sign', // inferred from taxonomy name
  'add_new_item'  => 'Divine New Sign', // overridden directly w/ labels.add_new_item
  'menu_naem'     => 'View Signs' // inferred from plural_label
  // ... other singular/plural labels are inferred in the same way
]
  ]);

no spaces. plus an optional "plural_label" index. It produces a more comprehensive array of labels before passing it to register_taxonomy(). If true, passes null as the $object_type argument to register_taxonomy(), which is useful for declaring taxonomies across post types. Defaults to false.

###### Examples of Post::register_type()
  Post::register_type('person', [
'plural_label' => 'People',
'labels' => [
  'add_new_item' => 'Onboard New Person'
],
  ]);
// equivalent to:
  register_post_type('person', [
'label' => 'Person', // inferred from post_type,
'labels' => [
  'singular_name' => 'Person', // inferred from post_type
  'add_new_item' => 'Onboard New Person', // overridden directly w/ labels.add_new_item
  'view_items' => 'View People', // inferred from plural_label
  // ... other singular/plural labels are inferred in the same way
],
  ]);

plus an optional "plural_label" index. It produces a more comprehensive array of labels before passing it to register_post_type(). ```

This class extends \Timber\Post

This class implements \Timber\CoreInterface

results matching ""

    No results matching ""