LemonPost
All custom post types will use this class as a base class unless you specifically create a new class that does not extend this class.
This class is used to extend the Timber Post class to add supporting methods for your post types.
Overview
This class extends Timber\Post
Methods
| Name | Return Type | Summary/Returns |
|---|---|---|
| get_archive_page() | array or false | Method to get the archive page for the post type. Returns: The archive link. |
| get_excerpt() | string | Custom excerpt. Returns: Returns the excerpt. |
| get_other_items() | \Timber\PostCollectionInterface or array | Method to get other post items. Returns: The other items. |
Class Methods
get_archive_page()
Method to get the archive page for the post type.
Returns: array|false The archive link.
get_excerpt()
Custom excerpt.
This method if a wrapper around the excerpt method. It allows you to get a custom excerpt for the post with predefined settings.
In case you have an empty excerpt, please add your custom blocks that are most likely used on the top of the page to the the excerpt_allowed_wrapper_blocks filter .
TODO: Use this function inside our twig templates and deprecated the lemon_excerpt function inside Twig files.
get_excerpt( string|int $length = 100 )
Returns: string Returns the excerpt.
| Name | Type | Description |
|---|---|---|
| $length | string or int | Amount of characters, if -1 all characters are returned. |
get_other_items()
Method to get other post items.
get_other_items( int $number, string $taxonomy = null, array $terms = [] )
Returns: \Timber\PostCollectionInterface|array The other items.
| Name | Type | Description |
|---|---|---|
| $number | int | The number of items to get. |
| $taxonomy | string | Name of the taxonomy to query. |
| $terms | array | ID of the term to query inside $taxonomy. |
Twig
{% include 'components/other-items.twig' with {
more: {
title: __('Bekijk gerelateerde vacatures', 'wp-lemon-child'),
items: post.get_other_items(2, 'category', [12,34]),
classes: ['section'],
button: false
},
card_type: 'job',
link: true
} %}