Query for multiple post types does not work

I’d like my frontpage to display a list of my lastest blog posts merged with my latest “Products” custom post type posts. From the documentation i gather this should work: query_posts( array(‘post_type’ => array(‘post’, ‘product’) ) ); while (have_posts()) : the_post(); the_title(); the_excerpt(); endwhile; But that turns a weird list, made of pages ! Note … Read more

Need post_type_archive_title function but in ‘single’

I’m trying to pull a custom post type name/title out for use in the breadcrumb of a single-[cpt].php template file. In the archive-[cpt].php I can use post_type_archive_title() and it echo the name. How would I get this same title in a single view? Thanks! I’ve trawled though the codex and haven’t seen a function, but … Read more

Function to get permalink of custom post type archives?

Is there a function that will return the permalink to a custom post types archives that is available to use in WordPress? Something like: get_cpt_permalink(“events”) which will return http://example.com/events/ when has_archive => true on it. If not what would I need to home brew my own? I’m thinking I would need to read $wp_rewrite and … Read more

Loop through posts of a custom-post-type (event) and create .ics (iCal) file?

I really need your help with a feature I have never worked with so far. I have a custom-post-type named wr_event. And I created this custom WP_Query to retrieve all posts for this post-type that are “younger” than yesterday. Fairly simple and this works like a charm. function event_list_iCal() { $yesterday = time() – 24*60*60; … Read more

How to remove slug metabox from custom post type’s page?

I just discovered a new meta field on the newly created custom post type page. The meta name is slug, and it’s under the wp editor field. What’s that, and how can I remove it? 2 Answers 2 You can remove the slug metabox from a post type with remove_meta_box: add_action( ‘add_meta_boxes’, ‘my_add_meta_boxes’ ); function … Read more

Prevent page slug from interfering with custom post type archive permalink?

In my plugin, I’m creating a custom post type that has an archive and uses the rewrite parameter to choose a slug: $args = array ( ‘public’ => true, ‘has_archive’ => true, ‘rewrite’ => array(‘slug’ => ‘lessons’, ‘with_front’ => false) ); register_post_type (‘my_plugin_lesson’, $args); With this code, I get an archive of the ‘my_plugin_lesson’ posts … Read more

If post_type is This or This

I’m basically using this bit of code in my functions.php to order my custom post types by title in ascending order. function set_custom_post_types_admin_order($wp_query) { if (is_admin()) { $post_type = $wp_query->query[‘post_type’]; if ( $post_type == ‘games’) { $wp_query->set(‘orderby’, ‘title’); $wp_query->set(‘order’, ‘ASC’); } if ( $post_type == ‘consoles’) { $wp_query->set(‘orderby’, ‘title’); $wp_query->set(‘order’, ‘ASC’); } } } add_filter(‘pre_get_posts’, … Read more