Add Categories column to custom post type in WordPress
This code is used for the list of all post-show this list you add one more column in the categories column.
Taxonomy is = solutionsconsole solutions is = Post Type <?php add_filter( 'manage_solutions_posts_columns', 'my_edit_movie_columns' ) ; function my_edit_movie_columns( $columns ) { $columns['solutionsconsole'] = __( 'Categories', 'your_text_domain' ); return $columns; } add_action( 'manage_solutions_posts_custom_column' , 'custom_book_column', 10, 2 ); function custom_book_column( $column, $post_id ) { global $post; switch( $column ) { case 'solutionsconsole' : /* Get the solutions for the post. */ $terms = get_the_terms( $post_id, 'solutionsconsole' ); /* If terms were found. */ if ( !empty( $terms ) ) { $out = array(); /* Loop through each term, linking to the 'edit posts' page for the specific term. */ foreach ( $terms as $term ) { $out[] = sprintf( esc_html( sanitize_term_field( 'name', $term->name, $term->term_id, 'solutionsconsole', 'display' ) ) ); } /* Join the terms, separating them with a comma. */ echo join( ', ', $out ); } /* If no terms were found, output a default message. */ else { _e( 'No Categories Solutions' ); } break; /* Just break out of the switch statement for everything else. */ default : break; } } ?>
Author: Learn Tutorials Point
We Well organized and easy-to-understand Interactive tutorials With lots of examples of how to use Tutorials WordPress, PHP, Bootstrap, Bootstrap 4, HTML, CSS, AJAX, jQuery, Woocommerce, Post, Database, Javascript, Theme, Responsive, Templates.
Trending Posts
Tags
ACF
Ading custom columns
admin
Bootstrap
Cart Price
categories
Change Price
class
Code
comments
Create
Creating custom post Type
CSS
current
custom
Customizing
Custom Post
Custom Post Type
Custom Taxonomy
database
Date
Fatch
form
function
HTML
Image
Install
javascript
jQuery
Menu
PHP
Post
Post Type
Price
product
responsive
Resular price
Single product
Table
taxonomy
Theme
Title
woocommerce
Wordpress
Wordpress Code