Paginate Custom Post Type Page

The following works for me (I’ve removed all the formating / custom post meta). I would add, its not clear why you need to use a page with a custom template, and don’t instead create a template called archive-portfolio.php which is used for a custom post type’s archive pages (see template hierarchy) <?php /* Template … Read more

How to display recent posts added in custom post types

The answer is essentially in Codex! <h2>Recent Posts</h2> <ul> <?php $recent_posts = wp_get_recent_posts(array(‘post_type’=>’book’)); foreach( $recent_posts as $recent ){ echo ‘<li><a href=”‘ . get_permalink($recent[“ID”]) . ‘” title=”Look ‘.esc_attr($recent[“post_title”]).'” >’ . $recent[“post_title”].'</a> </li> ‘; } ?> </ul> The only thing I did was add an argument to search for the book post type instead of the default … Read more

Define menu_order on Creation of New Custom Post?

Hi @fxfuture: I think what you are looking for is the wp_insert_post_data hook. You can add this code to the bottom of your theme’s functions.php file and/or you can add it to a plugin: add_filter(‘wp_insert_post_data’,’my_wp_insert_post_data’,10,2); function my_wp_insert_post_data($data, $postarr) { $post_type=”video”; if ($data[‘post_type’]==$post_type && get_post($postarr[‘ID’])->post_status==’draft’) { global $wpdb; $data[‘menu_order’] = $wpdb->get_var(“SELECT MAX(menu_order)+1 AS menu_order FROM {$wpdb->posts} … Read more

Pagination gives 404 error

Have you tried this? I had gotten the same problem before. I did these steps, and it works for me. I use this code in my functions.php // New method of WordPress Query since 3.4.1 if ( ! function_exists( ‘ucc_add_cpts_to_pre_get_posts’ ) ) { function ucc_add_cpts_to_pre_get_posts( $query ) { if ( $query->is_main_query() && ! is_post_type_archive() && … Read more

Add Taxonomy Values Within a Custom Post Type RSS Feed

get_post_meta is only for custom fields. If listing_category and listing_type are in fact taxonomies, you need to use get_the_terms instead. The resulting code would be something like this: add_action(‘rss2_item’, ‘yoursite_rss2_item’); function yoursite_rss2_item() { if (get_post_type()==’listings’) { $fields = array( ‘listing_bedrooms’, ‘listing_city’, ); $post_id = get_the_ID(); foreach($fields as $field) { if ($value = get_post_meta($post_id,$field,true)) { echo … Read more

Dropdown list of a custom post type

You’ll need to use get_posts and roll your own drop down. Something like this (somewhere in functions.php): <?php function wpse34320_type_dropdown( $post_type ) { $posts = get_posts( array( ‘post_type’ => $post_type, ‘numberposts’ => -1 ) ); if( ! $posts ) return; $out=”<select id=”wpse34320_select”><option>Select a Doctor</option>”; foreach( $posts as $p ) { $out .= ‘<option value=”‘ . … Read more

Custom edit post column – category not showing

Here I tested this code and its working fine and steps here. I am just creating a dummy custom_post_type here book with the following code. function kv_custom_post_books() { $args = array( ‘public’ => true, ‘label’ => ‘Books’, ‘taxonomies’ => array(‘category’, ‘post_tag’) , ‘supports’ => array( ‘title’, ‘editor’, ‘thumbnail’ ) ); register_post_type( ‘book’, $args ); } … Read more