Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Post_Type support ? #96

Open
anthonymasure opened this issue Apr 29, 2012 · 0 comments
Open

Custom Post_Type support ? #96

anthonymasure opened this issue Apr 29, 2012 · 0 comments

Comments

@anthonymasure
Copy link

Hi,

Thank you for your awesome Lifestream Plugin !
Did you plan to upgrade the plugin in the WordPress repository, or do I have to download the latest version here ?
Is http://wordpress.org/extend/plugins/lifestream-update/ the new and good link ?

//

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 648 :

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')
        ));

Then, the function who create a post_type for each event is located line 1977 :

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 : post edit, tags, categories, thumbnails...

I'm able to show 'lsevent' post_types in WP Admin with this code (replacing yours) :

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 events, for exemple query all events (google reader, tweets...) relative to "WordPress" subject (by tagging evnts with the "WordPress" tag. Usefull !

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant