Added Custom Post Type Support
-
I added custom post type support to this plugin.
Edit the ical-feeds.php
1) after this line:
echo '<p id="categoriesUrl" style="display: none;">'.__('URL:', ICALFEEDS_TEXTDOMAIN).' <a href="'.site_url().'/?ical&category=" data-baseUrl="'.site_url().'/?ical&category=" target="_blank">'.site_url().'/?ical&category=</a></p>';
add this:
echo '<h2>'.__('Post Type iCal feeds', ICALFEEDS_TEXTDOMAIN).'</h2>'; echo '<ul>'; $args = array( 'public' => true, '_builtin' => false ); $post_types = get_post_types($args); foreach ($post_types as $post_type) { echo '<li><a href="'.site_url().'/?ical&posttype='.$post_type.'" target="_blank">'.site_url().'/?ical&posttype='.$post_type.'</a> — '.__('Public iCal feed for', ICALFEEDS_TEXTDOMAIN).' '.$post_type.'</li>'; } echo '</ul>';
2) after this line:
if (!isset($options['icalfeeds_minutes'])) $options['icalfeeds_minutes'] = 60;
add this:
$post_type = 'post'; if (isset($_GET['posttype'])) { $post_type = $_GET['posttype']; }
3) replace both of the quires with this:
// Get posts if (isset($_GET['category'])) { $posts = $wpdb->get_results("SELECT $wpdb->posts.ID, $wpdb->posts.post_content, UNIX_TIMESTAMP($wpdb->posts.post_date) AS post_date, $wpdb->posts.post_title FROM $wpdb->posts LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.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 (".$postCond.") AND $wpdb->posts.post_type = '$post_type' AND $wpdb->term_taxonomy.taxonomy = 'category' AND $wpdb->term_taxonomy.term_id IN (".implode(',', $categoryIds).") ORDER BY post_date DESC $limit"); } else { $posts = $wpdb->get_results("SELECT $wpdb->posts.ID, $wpdb->posts.post_content, UNIX_TIMESTAMP($wpdb->posts.post_date) AS post_date, $wpdb->posts.post_title FROM $wpdb->posts WHERE (".$postCond.") AND $wpdb->posts.post_type = '$post_type' ORDER BY post_date DESC $limit"); }
4) I also changed X-WR-CALDESC variable to:
X-WR-CALDESC:Posts from {$blog_name}
Hope this can be implemented in the core plugin.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Added Custom Post Type Support’ is closed to new replies.