Display
Display class
Namespace: WebberZone\Contextual_Related_Posts\Frontend
Since: 3.5.0
Source: includes/frontend/class-display.php line 22
Methods
__construct()
Constructor class.
Since: 3.5.0
Line: 29
public function __construct( );
related_posts() static
Retrieves and displays related posts based on the given arguments.
Since: 3.5.0
Line: 53
static public function related_posts( $args = ... ): string;
| Type | Name | Description |
|---|---|---|
array | $args | { |
Returns: string — The formatted list of related posts.
get_default_args() static
Get the default arguments for related_posts(), including the saved settings.
Since: 4.3.0
Line: 301
static public function get_default_args( ): array;
Returns: array — Default arguments array.
get_posts() static
Retrieves an array of the related posts.
The defaults are as follows:
Since: 3.5.0
Line: 329
static public function get_posts( $args = ... ): \WP_Post[]|int[];
| Type | Name | Description |
|---|---|---|
array | $args | Optional. Arguments to retrieve posts. See WP_Query::parse_query() for all available arguments. |
Returns: \WP_Post[]|int[] — Array of post objects or post IDs.
exclude_on() static
Processes exclusion settings to return if the related posts should not be displayed on the current post.
Since: 3.5.0
Line: 352
static public function exclude_on( $post = ..., $args = ... ): bool;
| Type | Name | Description |
|---|---|---|
int|\WP_Post|null | $post | Post ID or post object. Defaults to global $post. Default null. |
array | $args | Parameters in a query string format. |
Returns: bool — True if any exclusion setting is matched.
should_cache() static
Check if the output should be cached.
Since: 3.5.0
Line: 412
static public function should_cache( $args ): bool;
| Type | Name | Description |
|---|---|---|
array | $args | Arguments to retrieve posts. |
Returns: bool — True if the output should be cached.
get_the_excerpt() static
Function to create an excerpt for the post.
Since: 3.5.0
Line: 429
static public function get_the_excerpt( $post, $excerpt_length = ..., $use_excerpt = ..., $more_link_text = ..., $strip_stopwords = ... ): string;
| Type | Name | Description |
|---|---|---|
int|\WP_Post | $post | Post ID or WP_Post instance. |
int|string | $excerpt_length | Length of the excerpt in words. |
bool | $use_excerpt | Use excerpt instead of content. |
string | $more_link_text | Content for when there is more text. Default is null. |
bool | $strip_stopwords | Strip stopwords from the excerpt. Default is false. |
Returns: string — Excerpt
link_attributes() static
Returns the link attributes.
Since: 3.5.0
Line: 546
static public function link_attributes( $args, $result ): string;
| Type | Name | Description |
|---|---|---|
array | $args | Array of arguments. |
\WP_Post | $result | \WP_Post object. |
Returns: string — Space separated list of link attributes.
heading_title() static
Returns the heading of the related posts.
Since: 3.5.0
Line: 583
static public function heading_title( $args ): string;
| Type | Name | Description |
|---|---|---|
array | $args | Array of arguments. |
Returns: string — Space separated list of link attributes
before_list() static
Returns the opening tag of the related posts list.
Since: 3.5.0
Line: 616
static public function before_list( $args ): string;
| Type | Name | Description |
|---|---|---|
array | $args | Array of arguments. |
Returns: string — Space separated list of link attributes
after_list() static
Returns the closing tag of the related posts list.
Since: 3.5.0
Line: 640
static public function after_list( $args ): string;
| Type | Name | Description |
|---|---|---|
array | $args | Array of arguments. |
Returns: string — Space separated list of link attributes
before_list_item() static
Returns the opening tag of each list item.
Since: 3.5.0
Line: 665
static public function before_list_item( $args, $result ): string;
| Type | Name | Description |
|---|---|---|
array | $args | Array of arguments. |
\WP_Post | $result | \WP_Post object. |
Returns: string — Space separated list of link attributes
after_list_item() static
Returns the closing tag of each list item.
Since: 3.5.0
Line: 691
static public function after_list_item( $args, $result ): string;
| Type | Name | Description |
|---|---|---|
array | $args | Array of arguments. |
\WP_Post | $result | \WP_Post object. |
Returns: string — Space separated list of link attributes
get_the_title() static
Returns the title of each list item.
Since: 3.5.0
Line: 717
static public function get_the_title( $args, $result ): string;
| Type | Name | Description |
|---|---|---|
array | $args | Array of arguments. |
\WP_Post | $result | \WP_Post object. |
Returns: string — Space separated list of link attributes
get_the_author() static
Returns the author of each list item.
Since: 3.5.0
Line: 743
static public function get_the_author( $args, $result ): string;
| Type | Name | Description |
|---|---|---|
array | $args | Array of arguments. |
\WP_Post | $result | \WP_Post object. |
Returns: string — Space separated list of link attributes
get_permalink() static
Returns the permalink of each list item.
Since: 2.5.0
Line: 788
static public function get_permalink( $args, $result ): string;
| Type | Name | Description |
|---|---|---|
array | $args | Array of arguments. |
\WP_Post | $result | \WP_Post object. |
Returns: string — Space separated list of link attributes
list_link() static
Returns the formatted list item with link and and thumbnail for each list item.
Since: 3.5.0
Line: 814
static public function list_link( $args, $result ): string;
| Type | Name | Description |
|---|---|---|
array | $args | Array of arguments. |
\WP_Post | $result | \WP_Post object. |
Returns: string — Space separated list of link attributes
get_the_date() static
Returns the date.
Since: 3.5.0
Line: 872
static public function get_the_date( $args, $result ): string;
| Type | Name | Description |
|---|---|---|
array | $args | Array of arguments. |
\WP_Post | $result | \WP_Post object. |
Returns: string — Space separated list of link attributes
get_primary_term_name() static
Display the primary term for a given post.
Since: 3.5.0
Line: 899
static public function get_primary_term_name( $post, $term = ..., $echo_value = ... ): string|void;
| Type | Name | Description |
|---|---|---|
int|\WP_Post | $post | Post ID or \WP_Post object. |
string | $term | Term name. |
bool | $echo_value | Echo or return. |
Returns: string|void — Term name if $echo_value is true, void if false.
content_filter() static
Filter for ‘the_content’ to add the related posts.
Since: 3.5.0
Line: 920
static public function content_filter( $content ): string;
| Type | Name | Description |
|---|---|---|
string | $content | Post content. |
Returns: string — After the filter has been processed
generate_content() static
Helper for inserting crp code into or alongside content
Since: 3.5.0
Line: 980
static public function generate_content( $content, $crp_code ): string;
| Type | Name | Description |
|---|---|---|
string | $content | Post content. |
string | $crp_code | CRP generated code. |
Returns: string — After the filter has been processed
insert_after_paragraph() static
Helper for inserting code after a closing paragraph tag
Since: 3.5.0
Line: 1003
static public function insert_after_paragraph( $content, $crp_code, $paragraph_id ): string;
| Type | Name | Description |
|---|---|---|
string | $content | Post content. |
string | $crp_code | CRP generated code. |
int | $paragraph_id | Paragraph number to insert after. A negative value indicates counting from the end. |
Returns: string — After the filter has been processed
rss_filter() static
Filter to add related posts to feeds.
Since: 3.5.0
Line: 1041
static public function rss_filter( $content ): string;
| Type | Name | Description |
|---|---|---|
string | $content | Post content. |
Returns: string — Formatted content