Support » Fixing WordPress » Detect custom post type archive page

  • Resolved johnny_n


    I’m having a difficult time determining if an archive page is for a custom post type. I even upgraded to the nightlies of WP 3.1 to get access to the function:


    Yet it still won’t work. Am I doing something wrong?

    function custom_biblio_archive() {
    	if (is_post_type_archive() == 'bibliography') {
    	<h2>CONTENT HERE</h2>
    	<h1 class="entry-title"><?php wp_title(''); ?></h1>
Viewing 5 replies - 1 through 5 (of 5 total)
  • I’ve used this code
    if (get_post_type() == 'bibliography') {

    successfully in single custom post type pages. That’s where I started off with on the archives too and it didn’t work. I’m using CMS Press to generate the archive pages, I’m wondering if it’s throwing something off.

    According to this post, it should be working. Now that I’m using 3.1, maybe I should drop CMS Press… any ideas?

    Humm… ok, I’ve dropped CMS press and manually am setting taxonomy and post type, but still can’t get the is_post_type_archive() function to work..

    For what it’s worth, the WP architecture for the custom post types and taxonomies has caused me many headaches, particularly in the area of archives and URLs, so you’re not alone in your frustrations. Sorry, I have no solutions, just sympathy.

    Err, thanks. 😉

    I’m bailing for now since I think there is some sort of bug.

    There’s an interesting article that says WP 3.1 now supports post type archive templates and it’s true, it’s working for me.

    So we’ll go that route instead… bit of a pain for various reasons, but it works.

    Aha. This works.
    if (get_post_type() == 'bibliography' && is_archive()) {

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Detect custom post type archive page’ is closed to new replies.