Technology TidBits

Answers to various technical questions on php programming, mysql, linux, and many more categories.
25% off Hosting at HostGator.com:
Use Code techbits25



How can I display editable content on my blog sidebar?

Last updated: 02/08/2012

The easiest way I found to do this, without adding plugins, etc. is to do the following:

1.  Add a new page, called something like "Sidebar Content".  Add the content you want to display, using images, links, etc (keep in mind the width of the sidebar especially with image widths.

2.  On the main "Edit pages" page, mouseover the page name (Sidebar Content), and note the URL at the bottom (page_id / post_id=) Get the post id number and write it down.

3. Edit your theme page - sidebar.php , or the correct area where your sidebar content should display.

4.  Add this chunk of code where you want the sidebar content to appear (replace "39" with your actual page id obtained in step 2):

<?php
$recent = new WP_Query("page_id=39");
while($recent->have_posts()) :
       $recent->the_post();
        the_content(); 
 endwhile;
?>

Now you can edit the page anytime, to edit the sidebar content!

 

blog comments powered by Disqus
Have your own Tech-bit to contribute? Submit it here

Other questions in this category:
How can I try out a new theme without making it live on my WordPress blog?
How can I set up a separate directory and have Wordpress ignore it?
How can I update my wordpress database when I change my domain / site name?
How can I upgrade to the latest version of wordpress?



Powered by KnowledgebasePublisher 1.1
Host Gator
Content provided by Roberts WebForge, Inc.