• I am using a plugin shortcode to view recent posts on a page. The shortcode specifies the category and limits to showing 5 posts.

    Is there a way to add php code after the shortcode to show a “message” if there are no posts, and to show a different message (i.e. “see all posts” linking to archive page) if there are more than 5 posts available in that category.

    Thanks.

Viewing 1 replies (of 1 total)
  • The only way to do what you want to do, without modifying the shortcode, is to look at the source code and replicate the Query on Posts that it did, and count the Posts, to create your own PHP code after the Shortcode has been run.

    If it were me, I’d probably just use the relevant PHP from the shortcode to display the posts and add the conditional code you mention, and get rid of the shortcode completely. Or build my own shortcode to replace it.

Viewing 1 replies (of 1 total)

The topic ‘Conditional statement used with shortcode’ is closed to new replies.