Forums

[resolved] PHP include to display one particular post (6 posts)

  1. jrelgin
    Member
    Posted 8 months ago #

    Hi All,

    I would like to display a message on my site that I will change occasionally. I thought it may be best to do this through a post that I occasionally edit the copy on. I want this message on every page so I plan to put it in my header.php.

    I'm not sure what function and parameters to call for this. I've tried:
    <?php query_posts('p=5'); ?>

    Am I on the right track or is this the wrong way of doing this?

    Thanks in advance!

  2. alchymyth
    The Sweeper
    Posted 8 months ago #

    good start;

    you will need the loop to output the post:
    http://codex.wordpress.org/The_Loop_in_Action

    and you will need to reset the query to have everything as it is for the rest of the page:
    http://codex.wordpress.org/Function_Reference/wp_reset_query

    using 'get_post()' is another possibility:
    http://codex.wordpress.org/Function_Reference/get_post

  3. jrelgin
    Member
    Posted 8 months ago #

    Great! Thank you alchymyth. You have definitely put me on the right track.

    What I'm trying to figure out now is how to display the post content and not the post title. Any suggestions?

    Thank you again

  4. Rev. Voodoo
    Volunteer Moderator
    Posted 8 months ago #

    withing your loop... just call the_content, and don't use the_title

  5. jrelgin
    Member
    Posted 8 months ago #

    thank you both—its working perfectly! I'm sure by now you can tell I'm a newb but thanks to people like you two, i'm learning!

  6. Rev. Voodoo
    Volunteer Moderator
    Posted 8 months ago #

    Gotta start somewhere, the codex, google, and these forums will be your friend!!

Reply

You must log in to post.

About this Topic