Making certain categories of CPT not publicly queryable

Sounds like you really just need a filter on pre_get_posts to remove the unwanted terms. Something like this, but I am not sure I understand all the conditions you need so think of it as proof of concept only. function exclude_terms_wpse_117242($qry) { if (is_user_logged_in()) { $tq = array( array( ‘taxonomy’ => ‘your_tax’, ‘field’ => ‘id’, … Read more

Hierarchical Custom Post Types in Array

It seems that you are looking to accomplish is a simple parent/child relationship with *n levels. I ran into something similar when working on subordinate posts https://github.com/codearachnid/wp-subordinate-post. The way I resolved the hierarchy (and even allowed for deep permalinking was to utilize the post_parent field. Based on your statements it seems like there might be … Read more

Want wp_get_post_terms return in arbitrarily order, how to do?

add_filter(‘the_content’,’my_function’); function my_function($content){ the_post_thumbnail(‘thumbnail’, array(‘class’ => ‘top-post-img’ )); if (is_single() && in_category(‘5′)){ global $post; $term_list = wp_get_post_terms ($post->ID,’school’,array(‘fields’=>’names’)); ?> <div id=”some_class”> <span>School:<strong><?php print_r($term_list[0]); ?></strong></span> <?php if (is_single() && in_category(‘5′)){ $term_list = wp_get_post_terms ($post->ID,’article’,array(‘fields’ =>’names’)); ?> <span>Article:<strong><?php print_r($term_list[0]); ?></strong></span> <?php if (is_single() && in_category(‘5′)){ $term_list = wp_get_post_terms ($post->ID,’teacher’,array(‘fields’=>’names’)); ?> <span>Teacher:<strong><?php print_r($term_list[0]); ?></strong></span> </div> <?php return $content; … Read more

Get custom post type list for every category shortcode

You are not dealing with categories. You are dealing with a custom taxonomy. $postlist_args = array( ‘posts_per_page’ => -1, ‘offset’ => 0, // ‘category’ => $category->cat_ID, // not this ‘tax_query’ => array( array( ‘taxonomy’ => ‘cars_category’, ‘field’ => ‘id’, ‘terms’ => $category->term_ID, ) ), ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’, ‘post_type’ => ‘msccar’, ‘post_status’ => … Read more

Custom Post Type With Categories

Hey Manan try this code: function codex_custom_init() { $labels = array( ‘name’ => ‘Prices’, ‘singular_name’ => ‘Price’, ‘add_new’ => ‘Add New’, ‘add_new_item’ => ‘Add New Price’, ‘edit_item’ => ‘Edit Price’, ‘new_item’ => ‘New Price’, ‘all_items’ => ‘All Prices’, ‘view_item’ => ‘View Price’, ‘search_items’ => ‘Search Prices’, ‘not_found’ => ‘No prices found’, ‘not_found_in_trash’ => ‘No prices … Read more