Hide child term posts on parent term pages

I think that the best solution is to hook into the pre_get_posts action hook. First, it is checked if we are in an archive of your custom taxonomy, then set include_children to false for the tax_query argument of the query. add_action( ‘pre_get_posts’, ‘cyb_pre_get_posts’ ); function cyb_pre_get_posts( $query ) { //Assuming the slug of the custom … Read more

Custom field values get deleted

Check your variables before you work with them. Your save function gets a parameter $post_id. Use it. From my meta box class for a check box: /** * Saves the content to the post meta. * * @return void */ public function save( $post_id ) { $this->is_allowed_save( $post_id ) and update_post_meta( $post_id, $this->vars[‘key’], empty ( … Read more

Make a select list of a custom post type in a meta box

very simeler to the question here Display list of tags as drop down menu or radio buttons in a meta box? but instead of list of tags you need to query the post list of your travellers post type something like this: $travelers = new WP_Query(); $travelers ->query(‘post_type=travelers&postprepage=-1’); while ($travelers->have_posts()) : $recentPosts->the_post(); $travellersnames[] = $post->title; … Read more

Custom permalinks – post type – hierarchical taxonomy’s

Thanks for referencing my solution. You forgot one part though – defining the rewrite of your cpt. From my solution: First get your slugs right when defining your custom post types and taxonomies: for the custom post type it should be basename/%taxonomy_name% and the slug for your taxonomy should be just basename. Dont forget to … Read more

Custom Permalinks for Custom post Type Archives?

Take an example custom post type called movie the code below will create custom permalinks awesomemovies/ regardless of the one created by using the has_archive and rewrite options of register_post_type. add_filter( ‘rewrite_rules_array’, ‘custom_permalink_for_my_cpt’ ); function custom_permalink_for_my_cpt( $rules ) { $custom_rules = array(); // for archive urls $custom_rules[‘awesomemovies/?$’] = ‘index.php?post_type=movie’; // for individual post urls e.g: … Read more