Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Quentin Véron

Filtering third-party column

Hello,

I was wondering: is there any way to enable filtering for third-party columns?

Here is my column for the post type fiche.

function gpc_fiche_columns( $columns ) {
    $columns['rubrique'] = __( 'Rubrique', 'gpc' );
    return $columns;
}
add_filter( 'manage_fiche_posts_columns', 'gpc_fiche_columns' );

function gpc_fiche_column( $column, $post_id ) {
    $theme = get_field( 'fiche-attachment', $post_id );
    $rubrique = get_field( 'theme-attachment', $theme );

    if ( $column === 'rubrique' && !empty ( $rubrique ) ) : ?>
        <a href="<?= get_edit_post_link( $rubrique ); ?>">
            <?= get_the_title( $rubrique ); ?>
        </a>
    <?php endif;
}
add_action( 'manage_fiche_posts_custom_column', 'gpc_fiche_column', 10, 2 );

Thank you.

5 years, 3 months ago
Stefan van den Dungen Gronovius
Developer

The only way to support filtering for a third-party column is to write an Admin Columns column on top of the original to replace it with our features and attach a so-called filtering modal to it.

Since you already created the custom column yourself, I would advice to rewrite your column completely for Admin Columns. We have a toolkit that can help you writing the column. You can also use this toolkit if you want to extend your column with our logic.

https://www.admincolumns.com/documentation/guides/creating-new-column-type/

I recently changed the toolkit to work with namespaced and also added a filtering and smart filtering example.
https://github.com/codepress/ac-column-template/tree/autoloader

5 years, 3 months ago

You must be logged in to reply to this topic.