is_post_type_archive example

if ( $content_found ) {
                $set_404 = false;
            }

            // We will 404 for paged queries, as no posts were found.         } elseif ( ! is_paged() ) {
            $author = get_query_var( 'author' );

            // Don't 404 for authors without posts as long as they matched an author on this site.             if ( is_author() && is_numeric( $author ) && $author > 0 && is_user_member_of_blog( $author )
                // Don't 404 for these queries if they matched an object.                 || ( is_tag() || is_category() || is_tax() || is_post_type_archive() ) && get_queried_object()
                // Don't 404 for these queries either.                 || is_home() || is_search() || is_feed()
            ) {
                $set_404 = false;
            }
        }

        if ( $set_404 ) {
            // Guess it's time to 404.             $wp_query->set_404();
            status_header( 404 );
            

function is_post_type_archive( $post_types = '' ) {
    global $wp_query;

    if ( ! isset( $wp_query ) ) {
        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
        return false;
    }

    return $wp_query->is_post_type_archive( $post_types );
}

/** * Determines whether the query is for an existing attachment page. * * For more information on this and similar theme functions, check out * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ * Conditional Tags} article in the Theme Developer Handbook. * * @since 2.0.0 * * @global WP_Query $wp_query WordPress Query object. * * @param int|string|int[]|string[] $attachment Optional. Attachment ID, title, slug, or array of such * to check against. Default empty. * @return bool Whether the query is for an existing attachment page. */
// If it's a search, use a dynamic search results title.     } elseif ( is_search() ) {
        /* translators: %s: Search query. */
        $title['title'] = sprintf( __( 'Search Results for “%s”' )get_search_query() );

        // If on the front page, use the site title.     } elseif ( is_front_page() ) {
        $title['title'] = get_bloginfo( 'name', 'display' );

        // If on a post type archive, use the post type archive title.     } elseif ( is_post_type_archive() ) {
        $title['title'] = post_type_archive_title( '', false );

        // If on a taxonomy archive, use the term title.     } elseif ( is_tax() ) {
        $title['title'] = single_term_title( '', false );

        /* * If we're on the blog page that is not the homepage * or a single post of any post type, use the post title. */
    } elseif ( is_home() || is_singular() ) {
        
$classes[] = 'page-item-' . $menu_item->object_id;
                $classes[] = 'current_page_item';
            }

            $active_parent_item_ids[]   = (int) $menu_item->menu_item_parent;
            $active_parent_object_ids[] = (int) $menu_item->post_parent;
            $active_object              = $menu_item->object;

            // If the menu item corresponds to the currently queried post type archive.         } elseif (
            'post_type_archive' === $menu_item->type
            && is_post_type_archive( array( $menu_item->object ) )
        ) {
            $classes[]                   = 'current-menu-item';
            $menu_items[ $key ]->current = true;
            $_anc_id                     = (int) $menu_item->db_id;

            while (
                ( $_anc_id = (int) get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) )
                && ! in_array( $_anc_id$active_ancestor_item_ids, true )
            ) {
                $active_ancestor_item_ids[] = $_anc_id;
            }

            

            ) ) {
                $classes[] = 'page-parent';
            }

            if ( $post->post_parent ) {
                $classes[] = 'page-child';
                $classes[] = 'parent-pageid-' . $post->post_parent;
            }
        }
    } elseif ( is_archive() ) {
        if ( is_post_type_archive() ) {
            $classes[] = 'post-type-archive';
            $post_type = get_query_var( 'post_type' );
            if ( is_array( $post_type ) ) {
                $post_type = reset( $post_type );
            }
            $classes[] = 'post-type-archive-' . sanitize_html_class( $post_type );
        } elseif ( is_author() ) {
            $author    = $wp_query->get_queried_object();
            $classes[] = 'author';
            if ( isset( $author->user_nicename ) ) {
                $classes[] = 'author-' . sanitize_html_class( $author->user_nicename, $author->ID );
                
Home | Imprint | This part of the site doesn't use cookies.