WordPress.org

Ready to get started?Download WordPress

Forums

WP-Lifestream2
Custom Post_Type support ? (1 post)

  1. anthonymasure
    Member
    Posted 2 years ago #

    Hi,

    Than you for upgrading the original Lifestream Plugin (maybe you can tell about the fork source in the description, because it confused people).

    I've seen that the plugin create a custom post_type 'lsevent' for each event imported.

    The code who register the post_type is located in inc/core.php line 662 :

    register_post_type('lsevent', array(
    			'label' => $this->__('Lifestream Events'),
    			'singular_label' => $this->__('Lifestream Event'),
    			'show_ui' => false,
    			'public' => true,
    			'exclude_from_search' => true,
    			'hierarchical' => false,
    			'capability_type' => 'post',
    			'rewrite' => array('slug', 'lifestream'),
    			'query_var' => false,
    			'can_export' => false,
    			'show_in_nav_menus' => false,
    			'supports' => array('title', 'comments')
    		));

    The n, the function who create a post_type for each event is located line 1961 :

    function create_post_for_event($event)
    	{
    		global $wpdb;
    
    		// TODO: find a better title
    		$post = array(
    			'post_title' => 'Lifestream Event',
    			'post_content' => '',
    			'post_status' => 'publish',
    			'post_author' => $event->owner_id,
    			'post_type' => 'lsevent',
    			// should we insert the feed types into the tags?
    			// 'tags_input' => ''
    			'post_date' => date('Y-m-d H:i:s', $event->timestamp),
    		);
    		$post_id = wp_insert_post($post);
    		$event->post_id = $post_id;
    		$event_list = array();
    		if ($event->is_grouped)
    		{
    			$wpdb->query($wpdb->prepare("UPDATE <code>&quot;.$wpdb->prefix.&quot;lifestream_event_group</code> set <code>post_id</code> = %d WHERE <code>id</code> = %d", $event->post_id, $event->id));
    			foreach ($event->data as $event)
    			{
    				// TODO: append to $event_list
    			}
    		}
    		else
    		{
    			$event_list[] = $event;
    		}
    		// TODO: process event list and update post ids
    	}

    So, my goal is to extend the possibilities of the plugin by using custom post_types capabilities : edit, tags, categories, thumbnails...

    I'm able to show 'lsevent' post_types in WP Admin with this code :

    register_post_type('lsevent', array(
    'label' => 'Lifestream',
    'singular_label' => 'Event',
    'show_ui' => true,
    'public' => true,
    'exclude_from_search' => true,
    'hierarchical' => false,
    'capability_type' => 'post',
    'rewrite' => true,
    'query_var' => true,
    'can_export' => false,
    'show_in_nav_menus' => false,
    'menu_position' => 4,
    'supports' => array('editor', 'title','excerpt', 'custom-fields', 'thumbnail'),
    'taxonomies' => array('category', 'post_tag'), // this is IMPORTANT
    '_builtin' => false, // It's a custom post type, not built in!
    ));

    But, the problem is that all 'lsevent' post_types are empty (they don't have content), so for the moment it's useless to query them.

    So, my question is : How can I do do allow the plugin to import the events contents in the post_types ? The content can be included in the content box and in the title... With this way of thinking, we will be able to categorize event, for exemple to query all events (google reader, tweets...) relative to "WordPress" subject, usefull !

    Thanks a lot for your advices.
    Anthony (from Paris)

    http://wordpress.org/extend/plugins/wp-lifestream2/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

  • RSS feed for this topic
  • Started 2 years ago by anthonymasure
  • This topic is not a support question
  • WordPress version: 3.3.2