Support » Plugins » I'm trying to update the iCal Posts plugin

  • Matthew


    I want an ical feed of events for a WP site I’m building and I came across this plugin called iCal Posts that does just that except that it hasn’t been updated in 3 years and so can’t grab posts from a specific category.

    I was able to update it to grab posts from a certain category, but for some reason it is grabbing all the revisions too. Is there something I’m doing wrong here?

    $posts = $wpdb->get_results("
    		SELECT wposts.*, UNIX_TIMESTAMP(post_date) AS post_date
    		FROM $wpdb->posts AS wposts
    		LEFT JOIN $wpdb->postmeta AS wpostmeta ON wposts.ID = wpostmeta.post_id
    		LEFT JOIN $wpdb->term_relationships ON (wposts.ID = $wpdb->term_relationships.object_id)
    		LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
    		WHERE wposts.post_status = 'publish'
    	    AND wposts.post_type = 'post'
    		AND $wpdb->term_taxonomy.taxonomy = 'category'
    		AND $wpdb->term_taxonomy.term_id IN($category_id)
    		ORDER BY post_date ASC
Viewing 3 replies - 1 through 3 (of 3 total)
  • Matthew


    Well, I never did figure this out, but I came up with a different solution. I created a page template to display an ical feed.

    <?php /* Template Name: iCal */
    header('Content-type: text/calendar');
    header('Content-Disposition: attachment; filename="ical_feed.ics"'); ?>
    PRODID:-//<?php bloginfo('name'); ?>//NONSGML v1.0//EN
    X-WR-CALNAME:<?php echo bloginfo('name'); ?>
    X-WR-TIMEZONE:<?php echo get_option('timezone_string');Ê?>
    X-ORIGINAL-URL:<?php bloginfo('url') ?>
    X-WR-CALDESC:<?php bloginfo('description'); ?>
    function filter_where($where = '') {
    		$where .= " AND post_date >= '" . date('Y-m-d H:i:s') . "'";
    		return $where;
    add_filter('posts_where', 'filter_where');
    $myposts = query_posts('numberposts=-1&orderby=post_date&order=asc&category_name=Events');
    foreach($myposts as $post) :
    setup_postdata($post); ?>
    DTSTART:<?php the_time('Ymd\THis'); ?>
    SUMMARY:<?php remove_filter('the_title', 'wptexturize'); the_title(); ?>
    DESCRIPTION:<?php the_permalink(); ?>
    <?php endforeach; ?>

    Obviously if you were to use this you would want to change some of the hardcoded values.

    Are you using this template with the plugin you mentioned? Will something like this work for a custom post type?



    I’m not using the plugin. I just made this page template to “fake” it, but it works pretty well. You could definitely use it with a custom post type, in fact, it would be probably better. You’d just need to change the query_posts.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘I'm trying to update the iCal Posts plugin’ is closed to new replies.