Hi @theblueli,
Sorting for the column is enabled. Just click on the heading.
Best regards from Spain.
Hi, I see.
However, it seems to be only working on the default post post type
Would you care to make it also available for the custom post type?
thanks
Hi @theblueli,
Sorting on custom types is quite tricky because it depends on the custom type slug.
Each custom post type needs a custom filter for the post-type:
add_filter( 'manage_edit-MY_POST_TYPE_sortable_columns', 'my_set_sortable_columns' );
where MY_POST_TYPE is the name of the custom post type.
And that’s why it’s not possible for us to include it in our plugin.
Best regards.
So I have a CPT named ‘school’
I use the Advance script plugin to enable this snippet
with
The snippet doesnt not add sortby for the modified date column. but also remove the sortby from other default columns. e.g. Date
https://ibb.co/99rhRZP
https://ibb.co/jfyQxGF
<?php
add_filter( 'manage_edit-school_sortable_columns', 'my_set_sortable_columns' );
Am I doing something wrong?
thanks
-
This reply was modified 4 years, 2 months ago by
theblueli.
Hi @theblueli,
The code was not complete. It was a generic example that you have to add the filter manage_edit-post_sortable_columns to sort columns.
For use with our plugin you need to use:
add_filter( 'manage_edit-school_sortable_columns', 'modified_column_register_sortable' );
The full code is:
function modified_column_register_sortable( $columns ) {
$columns['Modified'] = 'modified';
return $columns;
}
add_filter( 'manage_edit-school_sortable_columns', 'modified_column_register_sortable' );
Hope this helps.
Hello, the code breaks the site
https://ibb.co/nwDkqKd
But If I change ‘modified_column_register_sortable’ > to something else like ‘custom_column_register_sortable’
It works. Thanks~