Support » Fixing WordPress » Calendar widget – how to display posts from specific category only?

  • Hello,

    I’m using wordpress 2.9.1 with arthemia theme and calendar widget enabled in sidebar. I’d like the calendar widget to show posts only from a certain category (let’s say events) so basically it functions as events calendar. Currently the calendar displays posts from all categories.
    I’m rather new to wordpress and I’d appreciate any help on this subject. I tried searching for the solution, however haven’t found anything.

    Thank you,

Viewing 11 replies - 1 through 11 (of 11 total)
  • bump

    Not sure about it relates to the plugin, but you could put this in your sidebar template, or consider downloading and installing Otto’s PHP Code Widget and using the code in one of those widgets:

    //display all posts for category 5
          'cat' => 5,
          'post_type' => 'post',
          'post_status' => 'publish',
          'posts_per_page' => -1,
          'caller_get_posts'=> 1
        $my_query = null;
        $my_query = new WP_Query($args);
        if( $my_query->have_posts() ) {
          echo 'List of Posts';
          while ($my_query->have_posts()) : $my_query->the_post(); ?>
          <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
    wp_reset_query();  // Restore global post data stomped by the_post().

    Hi Michael,

    Thank you for your answer.
    I’m using the default wp calendar widget. This is the code from default-widgets.php:

     * Calendar widget class
     * @since 2.8.0
    class WP_Widget_Calendar extends WP_Widget {
    	function WP_Widget_Calendar() {
    		$widget_ops = array('classname' => 'widget_calendar', 'description' => __( 'A calendar of your blog’s posts') );
    		$this->WP_Widget('calendar', __('Calendar'), $widget_ops);
    	function widget( $args, $instance ) {
    		$title = apply_filters('widget_title', empty($instance['title']) ? '&nbsp;' : $instance['title']);
    		echo $before_widget;
    		if ( $title )
    			echo $before_title . $title . $after_title;
    		echo '<div id="calendar_wrap">';
    		echo '</div>';
    		echo $after_widget;
    	function update( $new_instance, $old_instance ) {
    		$instance = $old_instance;
    		$instance['title'] = strip_tags($new_instance['title']);
    		return $instance;
    	function form( $instance ) {
    		$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
    		$title = strip_tags($instance['title']);
    		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
    		<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>

    What should I change in there so it displays only posts from category X?

    Thank you.


    Have you looked at a plugin instead? Here’s one:

    Hi Michael,

    Thank you once again for your help. I know that plugin however it doesn’t suit my needs. It doesn’t support non-latin characters (which I have to use in my website) so unfortunately it’s a no on this one. I’d much rather use the default calendar widget and make it display posts only from a specific gallery.

    Can anyone point me in the right direction?

    Thank you in advance.


    Hi krko!!!

    Im having the same trouble as you are… if you found a way to solve it please let me know!!! either via this forum or twitter: ortizjp or email:


    krko, non latin character support was added in the development version

    hey guys, is any one found the solution to display the default calendar widget only for a specific category posts?

    I’d be interested in this answer too. I just want to use one category to display in the default calendar option.

    Another vote for very interested in the answer.

    if you want an events calendar, I came across this post……

    Read the description, its exactly what I need, however I have no idea where to put the script that has been created? If it makes sense to anyone else please let me know!!!!!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Calendar widget – how to display posts from specific category only?’ is closed to new replies.