Instantly share code, notes, and snippets.

Embed
What would you like to do?
add custom column content to taxonomy (carousel_category) list table page.
<?php
/*
* filter pattern: manage_{taxonomy}_custom_column
* where {taxonomy} is the name of taxonomy e.g; 'carousel_category'
* codex ref: https://codex.wordpress.org/Plugin_API/Filter_Reference/manage_$taxonomy_id_columns
*/
add_filter( 'manage_carousel_category_custom_column', 'wptc_carousel_category_column_content', 10, 3 );
function wptc_carousel_category_column_content( $content, $column_name, $term_id ) {
// get the term object
$term = get_term( $term_id, 'carousel_category' );
// check if column is our custom column 'carousel_shortcode'
if ( 'carousel_shortcode' == $column_name ) {
$shortcode = '<code>[wptc_carousel_slider category="'.$term->slug.'"]</code>';
$content = $shortcode;
}
return $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment