• Resolved cueyelink

    (@cueyelink)


    Hello, first I want to thank you for the great plugin. I am very happy with it.
    However, I have a question.
    I use your plugin on the front page and would like to display a default image if there are no posts on a certain date. Could you perhaps indicate what and where I should add this in the (php)code?

    [on_this_day title=”On this day…” posts_per_page=”1″ show_post_thumbnail=”true” show_post_excerpt=”false” show_post_date=”true” no_posts_message=”Try again later.”]
    —–> Image <——-

Viewing 4 replies - 1 through 4 (of 4 total)
  • There isn’t an option to display an image, just the text no_posts_message parameter. You might try putting an HTML <img> tag in as the value for that, but I don’t think it will work. (I haven’t tested that.)

    Thread Starter cueyelink

    (@cueyelink)

    Indeed, that doesn’t work. Tried that before. Too bad. I think it has to be done in the PHP-code.
    Maybe it’s an idea to think about an extra parameter (image if no posts) 😉
    Thanks for the reply

    I just tested putting an <img> tag into the no_posts_message parameter and it does work. You just need to be sure you don’t have any double quotes in the tag, because the shortcode parser reads them as the end of the parameter value. Since the parameter values are wrapped in double quotes, anything inside can’t have double quotes. If you change them to single quotes, it works.

    Thread Starter cueyelink

    (@cueyelink)

    Damn yes! That works.
    Many thanks.

    For those interested, here is the syntax:
    [on_this_day title="On this day..." posts_per_page="1" show_post_thumbnail="true" show_post_excerpt="false" show_post_date="true" no_posts_message="Please try again later <img src='https://your domain/wp-content/uploads/Noortje.webp' alt='Smelly Cat' width='500' height='600'>"]
    • This reply was modified 1 year, 7 months ago by cueyelink.
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Default image if no posts’ is closed to new replies.