Hi
I’m using a blog post element on a single custom post page to bring in news items (standard WP posts) related to the single custom post. See the example below:
The custom post type is “Development opportunities” and the single custom post is “Becket Street”. At the bottom of the page is “Related news and updates” where standard WordPress posts categorised as “Becket Street” are displayed via a Blog Post Element.
https://owe.brother.design/sites/becket-st-enabling-development/
Sometimes, there may be occasions where no related news items are available. When this happened is it possible for the Blog Post Element to have a fallback that simply reads “There are currently no related articles”?
Thanks in advance.
Dominic
Hey domchocolate,
Thank you for the inquiry.
Are you using the grid layout? If so, you will have to modify the config-templatebuilder/avia-shortcodes/postslider/postslider.php file and place the “no articles” text around line 665.
$output = '';
if( empty( $this->entries ) || ! $this->entries instanceof WP_Query || empty( $this->entries->posts ) )
{
return $output;
}
Example:
$output = '';
if( empty( $this->entries ) || ! $this->entries instanceof WP_Query || empty( $this->entries->posts ) )
{
$output = "There are currently no related articles";
return $output;
}
Best regards,
Ismael
Excellent – thanks Ismael, that worked a treat!
I did this so that I could add a class and control the look of it.
$output = '';
if( empty( $this->entries ) || ! $this->entries instanceof WP_Query || empty( $this->entries->posts ) )
{
$output = "<div class='no-articles'>There are currently no related articles</div>";
return $output;
}