Skip to content

Instantly share code, notes, and snippets.

@talentedaamer
Last active September 3, 2018 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talentedaamer/7f3d5ff4653e6c27eb9db3fc78289f4b to your computer and use it in GitHub Desktop.
Save talentedaamer/7f3d5ff4653e6c27eb9db3fc78289f4b to your computer and use it in GitHub Desktop.
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