Query/list all terms and their custom post count

If the taxonomies in question are used ONLY in the post_type in question, then the following simple function will do what you need: function count_term_use ($post_type) { $args = array ( ‘taxonomy’ => get_object_taxonomies ($post_type, ‘names’), ) ; foreach (get_terms ($args) as $term) { echo “$term->name – $term->count\n” ; } return ; } However, if … Read more

Keep display metadata value on backend – Custom Metabox

Modify your news_date() function to be as follows: function news_date( $post ) { wp_nonce_field( plugin_basename( __FILE__ ), ‘news_date_content_nonce’ ); // get the current value of ‘news_date’ to use in the <input> $value = get_post_meta ($post->ID, ‘news_date’, true) ; echo ‘<input type=”text” id=”news_date” name=”news_date” placeholder=”Enter Date” value=”‘ . $value . ‘”/>’; } Another suggestion would be … Read more

Custom posts don’t work

After custom post type registration, that is register_post_type() , try adding function flash_rewrite_rules(); This will automatically flush all rewrite rules so you won’t need to go to permalink settings each time. See this page: https://codex.wordpress.org/Function_Reference/register_post_type#Flushing_Rewrite_on_Activation Example: add_action( ‘init’, ‘my_cpt_init’ ); function my_cpt_init() { register_post_type( … ); flush_rewrite_rules(); } As it’s said in the docs, it’s … Read more

How I Can Delete Custom Post Type URL

If I correctly understand the question you’re asking, you don’t want your CPT to be directly available on the front-end. If so, then just set ‘public’ => false when you register the post_type. Remember that various other args to register_post_type() default to the value of public (e.g., show_ui), show when you set ‘public’ => false … Read more

custom post type not showing in menu

// portfolio code function codenovo_portfolio_init(){ $labels = array( ‘name’ => _x(‘Portfolio’, ‘post type general name’), ‘singular_name’ => _x(‘Portfolio’, ‘post type singular name’), ‘add_new’ => _x(‘Add New’, ‘portfolio’), ‘add_new_item’ => __(‘Add New Portfolio’), ‘edit_item’ => __(‘Edit Portfolio’), ‘new_item’ => __(‘New Portfolio’), ‘view_item’ => __(‘View Portfolio’), ‘search_items’ => __(‘Search Portfolio’), ‘not_found’ => __(‘No portfolio found’), ‘not_found_in_trash’ => … Read more

Get posts from a custom post type by child categories of a parent category

Your start looks already ok. You now need to get the posts which have the term_id of your $category. $categories = get_categories( array( ‘orderby’ => ‘name’, ‘child_of’ => 87, ‘order’ => ‘ASC’ ) ); foreach( $categories as $category ) { // display current term name echo $category->name; // display current term description, if there is … Read more