Support » Fixing WordPress » Custom post type archive broken in 3.2

  • Resolved kreestal

    (@kreestal)


    Hello guys,

    My custom post type archives are all broken on my WP 3.2 install.

    Of course I deactivated all my plugins, flushed my permalinks settings a dozen times, double checked my CPT had all the “has_archive” setting on “true”, even reinstalled WP 3.2 but it’s still broken.

    When I try to access to a CPT archive page, I don’t get a 404. Instead, the archive seems to display all my posts and CPT, breaks my sidebar and inserts such error messages :

    Warning: Illegal offset type in isset or empty in /path/to/my/site/wp-includes/post.php on line 825

    I did have the CPT archive working, but not anymore.

    Any idea whatr the problem could be please ? I searched on Google and here among the forums but so far with no luck.

    Many thanks in advance !

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter kreestal

    (@kreestal)

    I found what was causing this problem.

    In my functions.php file, I use this code to display custom post types in the loop on the homepage, the tag pages, and the author pages of my blog :

    add_filter( 'pre_get_posts', 'my_get_posts' );
    function my_get_posts( $query ) {
    	if ( ( is_home() || is_tag() || is_author() ) && empty( $query->query_vars['suppress_filters'] ) )
    		$query->set( 'post_type', array( 'post', 'my-custom-post-type' ) );
    	return $query;
    }

    I added is_archive() to this condition, which is pretty useless since WordPress does display the custom post types on any archive page since version 3.1.

    Removing it fixed my problem. Yay !

    hey. im having this same issue. where did you add is_archive()?

    Thread Starter kreestal

    (@kreestal)

    Hi crisherent !

    My mistake was to add is_archive() to the aforementioned function : that’s what caused the PHP error I was getting.

    Check if you don’t have is_archive() in the following function :

    add_filter( 'pre_get_posts', 'my_get_posts' );
    function my_get_posts( $query ) {
    	if ( ( is_home() || is_tag() || is_author() ) && empty( $query->query_vars['suppress_filters'] ) )
    		$query->set( 'post_type', array( 'post', 'my-custom-post-type' ) );
    	return $query;
    }

    (i.e. after is_author())

    If you don’t have such thing and you’re still getting the error, the best way to debug your problem is t deactivate all plugins => check if that fixes something ; if it doesn’t fixe it, clear your function.php file, to see if it fixes something.

    Hope this helps ?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom post type archive broken in 3.2’ is closed to new replies.