• Resolved allm

    (@realblueorange)


    If I want to manage the columns of the edit post screen I can use the filter manage_posts_columns. This will fire for posts as well as custom posts.

    If I want to manage the columns of a specific edit CUSTOM post screen I can use the filter manage_$post_type_posts_columns.

    What seems to be missing is a filter that only fires for posts, and not for custom posts. Or am I missing something? And if such a filter is not available, what would be a good way to get this to work?

    The codex has this info:
    https://codex.wordpress.org/Plugin_API/Filter_Reference/manage_posts_columns

    I have also looked here, but found no solution:

    Custom List Table Columns

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter allm

    (@realblueorange)

    I’ll answer it myself:

    After a lot of searching and trying this seems to work:

    add_filter( “manage_edit-post_columns” , ‘function1’ );
    add_action( “manage_post_custom_column” , ‘function2’, 99, 2 );

    Note that the action name is NOT manage_posts_custom_column (note the s) which will target COT’s as well.

    At least this is what now works for me.

    I’ll leave this thread open for a short while, just in case someone wants to shine a light on this as well…

    Thread Starter allm

    (@realblueorange)

    Sorry,

    add_action( "manage_post_custom_column" , 'function2', 99, 2 );

    will not work.

    Does anybody now what action will target only regular posts and NOT CPTs?

    Moderator bcworkz

    (@bcworkz)

    The action we use for CPTs is a dynamic hook: “manage_{$post->post_type}_posts_custom_column”

    You should be able to turn that around and use it exclusively for “post” post types with “manage_post_posts_custom_column”. This is an action distinct from ‘manage_posts_custom_column’ which fires for all non-hierarchical posts of any type.

    Thread Starter allm

    (@realblueorange)

    @bcworkz
    Thanks a lot! This seems to work. I thought I tried that first yesterday, but apparently not. Just to be thorough I also tried variations AND looked at the source to no avail.

    This helped me back on track. Thanks again. Have a great day!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘manage_posts_columns filter fires for CPT’s’ is closed to new replies.