Title: Conditional statement used with shortcode
Last modified: August 20, 2016

---

# Conditional statement used with shortcode

 *  [amysdaddy](https://wordpress.org/support/users/amysdaddy/)
 * (@amysdaddy)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/conditional-statement-used-with-shortcode/)
 * 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)

 *  [jon](https://wordpress.org/support/users/adiant/)
 * (@adiant)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/conditional-statement-used-with-shortcode/#post-2924193)
 * 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.

## Tags

 * [conditional](https://wordpress.org/support/topic-tag/conditional/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [jon](https://wordpress.org/support/users/adiant/)
 * Last activity: [13 years, 10 months ago](https://wordpress.org/support/topic/conditional-statement-used-with-shortcode/#post-2924193)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
