Last active
September 3, 2018 06:59
-
-
Save talentedaamer/7f3d5ff4653e6c27eb9db3fc78289f4b to your computer and use it in GitHub Desktop.
add custom column content to taxonomy (carousel_category) list table page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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