have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post(); $format = get_post_format(); if ( ( $format !=='image' ) ) { $portfolio = false; } endwhile; endif; } // Check if template should be displayed as archive-portfolio.php if ( is_post_type_archive( 'portfolio' ) || is_tax( 'post_format', 'post-format-image' ) || is_tax( 'portfolio_category' ) || is_tax( 'portfolio_tag' ) ) { $portfolio = true; } // Use the archive-portfolio.php template if ( $portfolio ) { $wp_query->set( 'portfolio_view', true ); $template = get_query_template( 'archive-portfolio' ); } return $template; } add_filter( 'template_include', 'camise_template_chooser' ); /** * Adds a body class to archives that display as a portfolio view * * @param array classes applied to post * @return array modified classes */ function camise_body_class( $classes ) { global $post; if ( is_page_template( 'templates/portfolio-page.php' ) || is_page_template( 'templates/portfolio-full-width.php' ) || is_page_template( 'templates/category-archive-page.php' ) || get_query_var( 'portfolio_view' ) ) { $classes[] = 'portfolio-view'; if ( of_get_option( 'camise_sidebar', false ) ) { $classes[] = 'full-width-portfolio'; } } // Remove the term "templates" from the page template body class // Primarily for backwards compatibility if ( isset( $post) && ( is_page_template( 'templates/full-width-page.php' ) || is_page_template( 'templates/portfolio-page.php' ) || is_page_template( 'templates/category-archive-page.php' ) || is_page_template( 'templates/portfolio-full-width.php' ) ) ) { foreach( $classes as $key => $value) { if ( $value == 'page-template-templatesfull-width-page-php') { $classes[$key] = 'page-template-full-width-page-php'; } if ( $value == 'page-template-templatesimage-gallery-formats-php') { $classes[$key] = 'page-template-image-gallery-formats-php'; } if ( $value == 'page-template-templatesfull-width-image-gallery-formats-php') { $classes[$key] = 'page-template-full-width-image-gallery-formats-php'; } } } if ( !of_get_option( 'camise_sidebar', false ) ) { if ( is_page_template( 'templates/portfolio-full-width.php' ) ) { $classes[] = 'full-width-portfolio'; } } return $classes; } add_filter( 'body_class','camise_body_class' ); /** * Adds additional category field for image on category archive. */ //add extra fields to category edit form hook add_action ( 'edit_category_form_fields', 'extra_category_fields'); //add extra fields to category edit form callback function function extra_category_fields( $tag ) { //check for existing featured ID $t_id = $tag->term_id; $cat_meta = get_option( "category_$t_id"); ?>