wp-lemon Docs

LemonPost

LemonPost

LemonPost

This class is used to extend the Timber Post class to add custom methods and properties.

Here we will add an example

PHP

my_method( 'example', false );

Overview

This class extends Timber\Post

Methods

NameReturn TypeSummary/Returns
get_archive_page()array or falseMethod to get the archive page for the post type.

Returns: The archive link.
get_excerpt()stringCustom excerpt.

Returns: Returns the excerpt.
get_other_items()\Timber\PostCollectionInterface or nullMethod 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.

NameTypeDescription
$lengthstring or intAmount of characters, if -1 all characters are returned.

get_other_items()

Method to get other post items.

get_other_items( int $number )

Returns: \Timber\PostCollectionInterface|null The other items.

NameTypeDescription
$numberintThe number of items to get.

Edit this page on GitHub