Custom post types – Use post_id in permalink structure

@Bainternet – your answer didn’t fully work but I did some more searching and was able to piece this filter together that did work: add_filter(‘post_type_link’, ‘custom_event_permalink’, 1, 3); function custom_event_permalink($post_link, $id = 0, $leavename) { if ( strpos(‘%event_id%’, $post_link) === ‘FALSE’ ) { return $post_link; } $post = &get_post($id); if ( is_wp_error($post) || $post->post_type != … Read more

register_post_type sort order by title by default

You could force the order via pre_get_posts: function wpa_order_states( $query ){ if( !is_admin() ) return; $screen = get_current_screen(); if( ‘edit’ == $screen->base && ‘states’ == $screen->post_type && !isset( $_GET[‘orderby’] ) ){ $query->set( ‘orderby’, ‘title’ ); $query->set( ‘order’, ‘ASC’ ); } } add_action( ‘pre_get_posts’, ‘wpa_order_states’ );

Adding Custom Post Type Counts to the Dashboard

Yes, there are several actions within that widget, including right_now_content_table_end. Example: function my_right_now() { $num_widgets = wp_count_posts( ‘widget’ ); $num = number_format_i18n( $num_widgets->publish ); $text = _n( ‘Widget’, ‘Widgets’, $num_widgets->publish ); if ( current_user_can( ‘edit_pages’ ) ) { $num = “<a href=”https://wordpress.stackexchange.com/questions/5318/edit.php?post_type=widget”>$num</a>”; $text = “<a href=”https://wordpress.stackexchange.com/questions/5318/edit.php?post_type=widget”>$text</a>”; } echo ‘<tr>’; echo ‘<td class=”first b b_pages”>’ . … Read more

group search results by post type?

You can run the same loop multiple times by using rewind_posts() to output each type separately. if( have_posts() ){ $types = array(‘post’, ‘lesson’, ‘series’); foreach( $types as $type ){ echo ‘your container opens here for ‘ . $type; while( have_posts() ){ the_post(); if( $type == get_post_type() ){ get_template_part(‘content’, $type); } } rewind_posts(); echo ‘your container … Read more

How to get the custom post type from an archive page?

There are a several of ways to do this. Put: var_dump($wp_query->query,get_queried_object()); die; In your archive.php and you should see two of those ways. $wp_query->query will have post_type component for custom post types. That will not be there for post post types. get_queried_object will return quite a bit of data for custom post types but null … Read more