WordPress.org

Ready to get started?Download WordPress

Forums

Custom Bulk/Quick Edit by Aihrus
[resolved] Isssues getting this started (11 posts)

  1. widecast
    Member
    Posted 8 months ago #

    Hey there,

    I'm trying to get your plugin to work with regular post types. If it works with that, I'll likely purchase the premium version as I need this to work with custom post types.

    This is the code I used to display a test custom column:

    add_filter( 'manage_posts_columns', 'my_manage_posts_columns' );
    function my_manage_posts_columns( $columns ) {
    	$columns['wpcf-price'] = 'Price';
    	return $columns;
    }
    
        add_action('manage_posts_custom_column', 'my_show_columns');
        function my_show_columns($name) {
        global $post;
        switch ($name) {
        case 'wpcf-price':
        $price = get_post_meta($post->ID, 'wpcf-price', true);
        echo $price;
        }
        }

    1. I wasn't able to display the custom field value until I added the manage_posts_custom_column action. This wasn't mentioned in the set up instructions at https://aihrus.zendesk.com/entries/24800411-How-do-I-add-custom-columns-to-my-edit-page- so I'm wondering if this was a required step or if it just assumed people knew how to do it. The custom field value wasn't displayed until I added it this second snippet.

    2. I actually still can't quick edit the "Price" yet. The price is now listed in it's own custom column but when I hit the quick edit button, it isn't displayed. I don't see any plugin settings that need to be toggled to get this working. Am I missing something?

    Thanks so much. Excited to get this running!

    David

    http://wordpress.org/plugins/custom-bulkquick-edit/

  2. Michael Cannon
    Member
    Plugin Author

    Posted 8 months ago #

    David,

    Thank you for writing.

    Be careful of the filter names, they're very confusing when dealing with columns and edit points. Try the following instead…

    add_filter( 'manage_post_posts_columns', 'my_manage_post_posts_columns' );
    function my_manage_post_posts_columns( $columns ) {
    	$columns['wpcf-price'] = esc_html__( 'Price' );
    
    	return $columns;
    }

    Then, once you've added your fields, go back to WP Admin > Settings > Custom Bulk/Quick, Posts tab to enable them.

    What's one thing I could do to improve the documentation to make this stuff more clear?

  3. widecast
    Member
    Posted 8 months ago #

    Hi Michael,

    I see now. Looks like when using "manage_posts_columns" the plugin doesn't recognize the new fields. After switching to "manage_post_posts_columns" I am able to enable them as quick-editable.

    That was my mistake for deviating from your example.

    However, I wasn't able to see any of the custom field values in the columns until I added the "add_action" part to populate the values. I'm not sure if that's expected behavior or not. If it is a required step, which it sees to be, it should be mentioned in the documentation.

    Interesting plugin. Seems to be working now.

  4. Michael Cannon
    Member
    Plugin Author

    Posted 8 months ago #

    David,

    I see know what you mean.

    In reading, http://codex.wordpress.org/Plugin_API/Filter_Reference/manage_posts_columns, I find that some finagling to support this filter is needed. I'll push out support for it later on.
    --
    manage_posts_columns is a filter applied to the columns shown on the manage posts screen. It's applied to posts of all types except pages. To add a custom column for pages, hook the manage_pages_columns filter. To add a custom column for specific custom post types, hook the manage_$post_type_posts_columns filter.

  5. Michael Cannon
    Member
    Plugin Author

    Posted 8 months ago #

    Also, we're you already working with another plugin or something that was using that filter?

  6. widecast
    Member
    Posted 8 months ago #

    The only reason I opted for the manage_posts_columns filter is because when I couldn't get the column data to populate using the example on your site I followed a different tutorial (http://www.deluxeblogtips.com/2010/05/add-custom-column.html) that teaches how to set up columns for custom field data.

    Still unclear about something. Is this part of my code necessary? The column values weren't displaying without it:

    add_action('manage_post_posts_custom_column', 'my_show_columns');
    function my_show_columns($name) {
        global $post;
        switch ($name) {
        case 'wpcf-price':
        $price = get_post_meta($post->ID, 'wpcf-price', true);
        echo $price;
        }
    }
  7. Michael Cannon
    Member
    Plugin Author

    Posted 8 months ago #

    Regarding that manage_posts_custom_column action, it shouldn't be needed as the default is to do what you're doing.

    If you have a dev system, could you please email support@aihr.us with an admin login for me to debug things?

  8. Michael Cannon
    Member
    Plugin Author

    Posted 8 months ago #

    David,

    If you want to use Custom Bulk/Quick Edit, I would suggest removing the other code and let's get your situation sorted out. Otherwise, it becomes a plugin conflict that's not covered by free support.

  9. widecast
    Member
    Posted 8 months ago #

    Hi Michael,

    I do see it all working as expected now. Awesome!

    I removed the "add_action" part and tested adding a new custom field, then added the column via your suggested method:

    add_filter( 'manage_post_posts_columns', 'my_manage_post_posts_columns' );

    I was then able to activate it via the plugin settings and the columns then populated correctly.

    I think I'm all set now. Will play around with it a bit more and then consider paying for the premium version as I would need this for a custom post type.

    Thanks for the help!

  10. Michael Cannon
    Member
    Plugin Author

    Posted 8 months ago #

    Fantastic news. Let me know if you need further help.

  11. Michael Cannon
    Member
    Plugin Author

    Posted 7 months ago #

    @widecast, I'll be releasing the integration of manage_pages_columns and manage_posts_columns early in the year. They're already in master at https://github.com/michael-cannon/custom-bulkquick-edit.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.