Permalink
Browse files

Add custom post type support

If the normal 'post' post_type is turned off, "p=<id>" queries don'twork because WP_Query forces these to
post_type = post. We're goingto work around this in Liveblog by querying
any post_type that hasliveblog support.

Background: http://core.trac.wordpress.org/ticket/21660
  • Loading branch information...
joshbetz committed Oct 16, 2013
1 parent 43c1fcc commit 504c28e359a98ed61fffec0f1cc6d2746a6095a7
Showing with 13 additions and 0 deletions.
  1. +13 −0 liveblog.php
View
@@ -76,6 +76,19 @@ public static function load() {
self::add_admin_actions();
self::add_admin_filters();
self::register_embed_handlers();
+ add_action( 'pre_get_posts', array( __CLASS__, 'add_custom_post_type_support' ) );
@nb

nb Dec 14, 2013

Owner

This line looks like the odd one out, compared to the few ones right before it. The add_actions() methods looks like a better place for it.

+ }
+
+ public static function add_custom_post_type_support( $query ) {
+ if ( ! get_query_var( 'liveblog' ) )
@nb

nb Oct 16, 2013

Owner

Is there a reason you didn’t use is_entries_ajax_request()?

@joshbetz

joshbetz Oct 17, 2013

Owner

@nb I was in a rush and didn't see it :) Thanks for the heads up. I'll fix it tomorrow.

+ return;
+
+ $post_types = array_filter( get_post_types(), array( __CLASS__, 'liveblog_post_type' ) );
+ $query->set( 'post_type', $post_types );
+ }
+
+ public static function liveblog_post_type( $post_type ) {
+ return post_type_supports( $post_type, self::key );
}
private static function add_old_wp_notice() {

0 comments on commit 504c28e

Please sign in to comment.