Support » Alpha/Beta/RC » How to get functions like wp_get_archives to work with Custom Post Types?

  • I can’t seem to use functions like wp_get_archives with Custom Post Types. These functions still return all the posts associated with the main blog posts.

    Is there any way of filtering out the Custom Post Types for functions like these?

    My issue is that I have both a blog and a news section. The blog uses all the standard templates and functions, but my News section is done with Custom Post Types. However, I still want to use all the standard blog features in the News section too.

    Is this possible?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Not really–you can use a Page Template and display the object in that post type though.

    Hi, thanks for the reply. “Display the object in that post type” — not entirely sure what you mean by this? What object?

    I should have use the word posts, or items.

      'post_type' => 'news',
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'caller_get_posts'=> 1
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      echo 'List of News Items';
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
    wp_reset_query();  // Restore global post data stomped by the_post().

    Ah, right, thanks. Yes, I thought about this but still wanted to use some of the built in stuff like displaying them in dated archives.

    What I’m trying to do is to have something like this: <- display using standard WP blog stuff <- custom post types

    For the News option, I’d ideally like to still filter them and manage them using all the standard WP functions.

    I thought about doing them as category slugs instead and setting ‘Blog’ and ‘News’ categories and not using custom post types for News. But to do this, I’d need to set the custom permalinks to “%category%” which I’ve read is a bad idea.

    Do you have any views on this, or suggestions for other ways I can accomplish this and still retain the correct child URLs for the different areas? Eg:

    Many thanks for any insights 🙂

    I think you’ll see more of that stuff in 3.1 or later.

    I hope so. It does seem a strange design decision to exclude custom post types from working with many of the core WP functions. I realise that’s a big job, but it does seem strange to bring out such a great feature that’s already half crippled from the start.

    One might have assumed that people will want to use all the standard WP functions with Custom Post Types and I think a lot of people are going to be disappointed when they discover that they can’t. It seems a bit of a missed opportunity. 🙁

    Yeah it’s going to be interesting to hear the clamor about that with 3.0. Part of the reason Otto at says you better have a darn good reason for using custom post types 😉

    I dip in and out of following WordPress development: I’m a bit out of the loop at the moment. Is there a good place to follow discussions on future developments of Custom Post Types? Cheers.

    One or more Mailing Lists.



    Don’t know if this was what you where looking for, but it worked for me, and I think I had the same problem as you.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘How to get functions like wp_get_archives to work with Custom Post Types?’ is closed to new replies.