WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Detect custom post type archive page (6 posts)

  1. johnny_n
    Member
    Posted 3 years ago #

    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:

    is_post_type_archive

    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>
    	<?php
    	}
    }
  2. johnny_n
    Member
    Posted 3 years ago #

    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?

  3. johnny_n
    Member
    Posted 3 years ago #

    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..

  4. fireproofsocks
    Member
    Posted 3 years ago #

    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.

  5. johnny_n
    Member
    Posted 3 years ago #

    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.

  6. johnny_n
    Member
    Posted 3 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic