WordPress.org

Ready to get started?Download WordPress

Forums

Admin Custom Post Type Column Sorting Not Working (1 post)

  1. leonhooijer
    Member
    Posted 7 months ago #

    Hello,

    I have added a custom column to my admin edit-posts overview (also for page and 3 other custom post types). This all works just fine, but when I try to make the column sortable this does only work for the default posts and pages.

    Here is my code:

    $args = array(
       'public'   => true,
    );
    $output = 'names'; // names or objects, note names is the default
    $operator = 'and'; // 'and' or 'or'
    $post_types = get_post_types( $args, $output, $operator );
    foreach ( $post_types as $post_type ) {
       add_filter("manage_edit-".$post_type."_sortable_columns", 'last_modified_sort');
    }

    Also when I change this code to:

    add_filter("manage_edit-home_slider_sortable_columns", 'last_modified_sort');
    add_filter("manage_edit-portfolio_sortable_columns", 'last_modified_sort');
    add_filter("manage_edit-nectar_slider_sortable_columns", 'last_modified_sort');

    Everything works fine. But the each-loop generates exactly the same output as the hardcoded lines.

    Anyone got any ideas?

Reply

You must log in to post.

About this Topic