Can I use custom post types to create a parent/child relationship?

I’m using this code for a metabox in a current project I’m working on: function parent_select ($parent_type) { global $post; global $wpdb; $query = “SELECT ID, post_title FROM $wpdb->posts WHERE post_type=”{$parent_type}” AND post_status=”publish” ORDER BY post_title”; $results = $wpdb->get_results($query, OBJECT); echo ‘<select name=”parent_id” id=”parent_id”>’; echo ‘<option value = “”>None</option>’; foreach ($results as $r) { echo … Read more

Remove tabs from media uploader for a CPT

You can use the media_upload_tabs filter check for your post type and unset any tab you don’t want ex: function remove_media_library_tab($tabs) { if (isset($_REQUEST[‘post_id’])) { $post_type = get_post_type($_REQUEST[‘post_id’]); if (‘premium’ == $post_type) unset($tabs[‘library’]); unset($tabs[‘type_url’]); } return $tabs; } add_filter(‘media_upload_tabs’, ‘remove_media_library_tab’);

Exclude from search all custom posts which are NOT in a taxonomy term

After reading your revised question it was easier to comprehend what you are trying to do. My new solution looks like the thing you wanted to do in the first place: it just excludes all posts which are of your custom type but don’t have the “yes”-term associated with it: $custom_query = array(); $custom_query[‘post_type’] = … Read more

Creating a Custom Post Types dropdown in a Meta Box

Of course it is possible. Below is code that will display registered post types: function my_meta_box_add() { add_meta_box( ‘my-meta-box-id’, ‘MY meta’, ‘my_meta_box’, ‘page’, ‘normal’, ‘high’ ); } add_action( ‘add_meta_boxes’, ‘my_meta_box_add’ ); function my_meta_box( $post ) { ?> <p> <label for=”my_meta_box_post_type”>Post type: </label> <select name=”my_meta_box_post_type” id=’my_meta_box_post_type’> <?php $post_types=get_post_types(”, ‘objects’); foreach ($post_types as $post_type): ?> <option value=”<?php … Read more

Custom Postype Query showing only 10 results should show 23 results

You need to add ‘posts_per_page’=>’-1′ to $args, so: <?php global $post; $i=1; $args = array( ‘order’ => ‘ASC’, ‘orderby’ => ‘post_date’, ‘post_status’ => ‘publish’, ‘post_type’ => ‘pacificheritage’, ‘posts_per_page’=>’-1′ ); ?> <?php if (have_posts()):?> <?php $list_of_posts = new WP_Query($args); while ($list_of_posts->have_posts()):$list_of_posts->the_post(); $meta = get_post_meta( get_the_ID(), ”); ?> <?php echo $post->ID; ?> <?php the_title(); ?><br/> <?php endwhile; … Read more