WordPress.org

Ready to get started?Download WordPress

Forums

AJAX Calendar
Category ID doesn't persist through months (3 posts)

  1. kristarella
    Member
    Posted 1 year ago #

    It seems like this has always been an issue in this plugin (forum thread from 3 years ago), but I'd love to find a fix for it...

    The category ID only filters the category on the first month that appears when the page & widget load, after that navigating through months shows all posts.

    I'm using this function to add the widget in my theme applying the category ID as the category of the first post on every page:

    function custom_ajax_widget() {
    	global $wp_query;
    	$id = $wp_query->post->ID;
    	$cats = get_the_category($id);
    	$catID = $cats[0]->cat_ID;
    
    	$instance = array(
    		'title' => '',
    		'category_id' => $catID
    	);
    	$args = array(
    		'before_widget' => '<li class="widget ajax_calendar_widget">',
    		'after_widget' => '</li>',
    		'before_title' => '<h3>',
    		'after_title' => '</h3>'
    	);
    	the_widget('AJAX_Calendar_Widget',$instance,$args);
    }

    It shouldn't make a difference to the behaviour of the widget, but might provide more flexibility in the solution to this problem, perhaps.

    http://wordpress.org/extend/plugins/ajax-calendar/

  2. chavo
    Member
    Posted 1 year ago #

    I noticed that this bug doesn't happens If you use the default widget, I mean, If you drag the widget from the admin panel.

    Anyway, I'm not a widget lover. I prefer to use template code. I tried your code and, in fact, It works ok on first load, but when you navigate trough months, all month links are displayed.

    I use a specific category ID. My code looks like this:

    <?php
    	$instance = array(
    		'title' => '',
    		'category_id' => 12
    	);
    	$args = array(
    		'before_widget' => '<li class="widget ajax_calendar_widget">',
    		'after_widget' => '</li>',
    		'before_title' => '<h3>',
    		'after_title' => '</h3>'
    	);
    	the_widget('AJAX_Calendar_Widget',$instance,$args);
    ?>

    I really would like to have ajaxified calendar filtering categories using template tags because of my need to add another aditional php code. But...it is getting really hard to figure out how to make it to work. Did you find any solution?

    ps: sorry for my english.

  3. kristarella
    Member
    Posted 1 year ago #

    I'm not sure why it wouldn't happen if using the widget... maybe it has something to do with the AJAX that is put out on the page, maybe that needs to be edited as well to use the category ID...
    I don't mind using widgets, I just needed to change the category according to the current post, so setting a specific category in the widget wasn't suitable.

    I haven't found a fix.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic