WordPress.org

Forums

Check If Posts Exists? (5 posts)

  1. solutionsphp
    Member
    Posted 7 years ago #

    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!

  2. MichaelH
    Member
    Posted 7 years ago #

    You have get_post and get_a_post so don't know if that's part of the problem.

  3. solutionsphp
    Member
    Posted 7 years ago #

    Thanks for your reply. The get_post method is from WordPress, while get_a_post from the Get A Post plugin.

  4. MichaelH
    Member
    Posted 7 years ago #

  5. jhz
    Member
    Posted 6 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags