• Matthew

    (@existentialmedia)


    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
    		$limit;");
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Matthew

    (@existentialmedia)

    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"'); ?>
    BEGIN:VCALENDAR
    VERSION:2.0
    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'); ?>
    
    CALSCALE:GREGORIAN
    METHOD:PUBLISH
    <?php
    date_default_timezone_set('America/Los_Angeles');
    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); ?>
    BEGIN:VEVENT
    DTSTART:<?php the_time('Ymd\THis'); ?>
    
    DURATION:PT1H0M0S
    SUMMARY:<?php remove_filter('the_title', 'wptexturize'); the_title(); ?>
    
    DESCRIPTION:<?php the_permalink(); ?>
    
    END:VEVENT
    <?php endforeach; ?>
    END:VCALENDAR

    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?

    Thread Starter Matthew

    (@existentialmedia)

    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.