Title: Check If Posts Exists?
Last modified: August 18, 2016

---

# Check If Posts Exists?

 *  [solutionsphp](https://wordpress.org/support/users/solutionsphp/)
 * (@solutionsphp)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/check-if-posts-exists/)
 * How can I check if a post exists, outside the Loop?
 * I’m trying to conditionally display a post using the Get A Post plugin. If the
   post doesn’t exist, I don’t want the DIV to display:
 *     ```
       <?php $announcement = get_post(27);
                if ($announcement) { ?>
                   <div id="announcements">
       			<?php get_a_post(27);
                                     the_content(); ?>
       		</div>
       	<?php } ?>
       ```
   
 * This returns “Fatal error: Cannot pass parameter 1 by reference”
 * Searched everywhere in here but didn’t find a solution. Thanks in advance!

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/check-if-posts-exists/#post-646666)
 * You have `get_post` and `get_a_post` so don’t know if that’s part of the problem.
 *  Thread Starter [solutionsphp](https://wordpress.org/support/users/solutionsphp/)
 * (@solutionsphp)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/check-if-posts-exists/#post-646676)
 * Thanks for your reply. The get_post method is from WordPress, while get_a_post
   from the Get A Post plugin.
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/check-if-posts-exists/#post-646718)
 * Then how about
    [http://codex.wordpress.org/Template_Tags/query_posts#Retrieve_a_Particular_Post](http://codex.wordpress.org/Template_Tags/query_posts#Retrieve_a_Particular_Post)
 *  [jhz](https://wordpress.org/support/users/jhz/)
 * (@jhz)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/check-if-posts-exists/#post-647019)
 * I love get_a_post ‘casue you can use it outside the loop. I’m trying to use it
   in the same way, to generate a specific post with special div styling. Was there
   a solution to using get_a_post (as opposed to get_post)? TIA!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Check If Posts Exists?’ is closed to new replies.

## Tags

 * [get-a-post](https://wordpress.org/support/topic-tag/get-a-post/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [jhz](https://wordpress.org/support/users/jhz/)
 * Last activity: [17 years, 10 months ago](https://wordpress.org/support/topic/check-if-posts-exists/#post-647019)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
