• Resolved widecast

    (@widecast)


    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/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Michael Cannon

    (@comprock)

    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?

    Thread Starter widecast

    (@widecast)

    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.

    Plugin Author Michael Cannon

    (@comprock)

    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.

    Plugin Author Michael Cannon

    (@comprock)

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

    Thread Starter widecast

    (@widecast)

    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;
        }
    }
    Plugin Author Michael Cannon

    (@comprock)

    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?

    Plugin Author Michael Cannon

    (@comprock)

    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.

    Thread Starter widecast

    (@widecast)

    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!

    Plugin Author Michael Cannon

    (@comprock)

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

    Plugin Author Michael Cannon

    (@comprock)

    @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.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Isssues getting this started’ is closed to new replies.