get_pages fails with Pods installed
-
I’m using two Custom Post Types (Event and Event Item). An Event can have multiple Event Items. Before discovering Pods I was using the post_parent in the Event Item CPT for the many-to-one relationship.
get_children()
andwp_get_post_parent_id()
fetched the relevant CPTs to display in the Theme.I establish the Event CPT’s ID in Event ID, I used the following:
add_action('add_meta_boxes', function() { add_meta_box('event', '<h1 style="color:red;">Choose An Event For This Item</h1>', 'event_meta_box', 'event_item', 'side', 'high'); }); function event_meta_box($post) { $pages = wp_dropdown_pages(array('post_type' => 'event', 'selected' => $post->post_parent, 'name' => 'parent_id', 'show_option_none' => __('SELECT EVENT'), 'sort_column'=> 'post_title', 'echo' => 0)); if ( ! empty($pages) ) { echo $pages; }
This creates a metabox in the Event Item with a dropdown of the Events.
However, this previously-working code stopped working with Pods installed. The metabox appears in the Admin UI but the dropbox with Events does not. I added this:
// test get_pages $checkpages = get_pages (array('post_type' => 'event'));
With Pods installed
wp_dropdown_pages
returns a empty string andget_pages
returns false. It works as soon as Pods is uninstalled.Yes, I know the Pods Way is to use a Relationship field (podsrel table) and that’s what I’ll do. I’m just curious why this stops working.
- The topic ‘get_pages fails with Pods installed’ is closed to new replies.