Populate sidebar with posts from a category
-
Hi,
I have several pages, each of which contains a particular training course details.
On the right of each page, I also want to have a list of training dates for the particular course.
I’ve copied the page.php file as a basis for a new template for the above purpose and now have a couple of the training pages linked.
For each of these training pages, I need to create one or more entries with heading as the date of the training, and the details covering location and a few other notes.
Can anyone advise on how I go about dynamically loading this list of training dates as per the selected training page on the right hand side of the page?
thanks
Matt
-
can be done in many ways, i am assuming you want the data to be displayed in the sidebar.
create a dynamic sidebar and use the page_id or course_id to get the data related to the course and show them in the sidebar.
thanks Santosh, yes you are spot on, that’s exactly what I want to do but was hoping for some guidance as to how as I’m new to WordPress and have only had limited experience with php so am kind of fumbling around a bit.
My training-template (copied from page.php) is listed below, and I suppose I should really try to understand what each part is doing – but as always, I’ve been given very little time to produce a result.
<?php /* Template Name: Training Template */ ?> <?php get_header();?> <!-- BEGIN OF PAGE TITLE --> <?php if (have_posts()) : ?> <div id="page-title"> <div id="page-title-inner"> <div class="title"> <h1><?php the_title();?></h1> </div> <div class="dot-separator-title"></div> <div class="description"> <?php global $post;?> <?php $short_desc = get_post_meta($post->ID, '_short_desc', true ); ?> <p><?php echo $short_desc;?></p> </div> </div> </div> <!-- END OF PAGE TITLE --> <!-- BEGIN OF CONTENT --> <div id="content"> <div id="content-left"> <div class="maincontent"> <?php while (have_posts()) : the_post();?> <?php the_content();?> <?php endwhile;?> </div> </div> <?php endif;?> <?php get_sidebar();?> </div> <!-- END OF CONTENT --> <?php get_footer();?>It would depend on the theme, if it is twenty ten based then you may have the sidebar menu widget?
If you do create a menu for each course, and use the widget logic plugin to switch these on and off.
So create a post for each event, then in Admin > Appearance > Menu create a menu, from Screen Options choose posts and add the posts to the different menu, these can even be indented under the page.
EG: menu ‘course1’
Course 1 (page)
–July 2011 (post drag right to indent)
–September 2011 (post)
–November 2011 (post)The add the menu widget to the sidebar and select the menu, save.
Install and activete Widget Logic, and then in the sidebar menu parameter something like
is_page('Course 1')Then only when the page ‘Course 1’ is loaded will the sidebar show the timetable menu.
Not something I would do as it is a bit of a mess.
A normal clean and easy way would be just to use the main menu or add hyperlinks in the page and posts, these can be text or images, so if I look at ‘Course 1’ I see a nice list of dates in the page, when I click on any date I can navigate to another date or back to the main page?
HTH
David
The topic ‘Populate sidebar with posts from a category’ is closed to new replies.