Support » Fixing WordPress » How to show single post content in sidebar
8 years, 3 months 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.
8 years, 2 months ago
Sorry to bump this old post, but how would you query a page instead of a post?
7 years, 10 months ago
Use the following for pages:
query_posts(‘page_id=7’); //retrieves page 7 only
Further details on the query_posts() function here:
You can always look up usage and examples in the wordpress codex 🙂
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.
7 years, 9 months 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. =(
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!