WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to show single post content in sidebar (6 posts)

  1. ars-novum
    Member
    Posted 5 years ago #

    1.) Create a post
    2.) Publish the post
    3.) Find out the post's ID (egg. 96)
    4.) Open your themes Sidebar.php
    5.) Include this code:

    <?php query_posts('p=96'); if(have_posts()) : the_post(); ?>
    <?php the_content(); ?>
    <?php endif; ?>

    P=THE ID OF YOUR POST!

    Then the whole post-content will be shown there.

    Cheers,

    Morris

  2. Jolva
    Member
    Posted 5 years ago #

    Sorry to bump this old post, but how would you query a page instead of a post?

  3. gbdesigner
    Member
    Posted 5 years ago #

    Use the following for pages:
    query_posts('page_id=7'); //retrieves page 7 only

    Further details on the query_posts() function here:
    http://codex.wordpress.org/Template_Tags/query_posts

    You can always look up usage and examples in the wordpress codex :)

  4. Digital Skraps
    Member
    Posted 5 years ago #

    this absolutely does not work for pages and when putting the original listed code in the sidebar, it kills the loop and returns an error for the main content region.

  5. Justadrumer
    Member
    Posted 5 years ago #

    wonder if I could bump this again.
    How could I pull this page like this but use an if statement to pull a specific page for each day of the week?
    I tried using something like this: http://wordpress.org/support/topic/249486 but I'm doing it wrong. =(

  6. dmccasland
    Member
    Posted 5 years ago #

    Hey this is just what I needed for my Announcement sidebar -- change the post, RSS picks it up, and the sidebar is updated! Perfecto! thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic