!Update 2018: Latest version of The7 already have this option. You can select Archive template from Theme options > Archives, refer to the documentation for details.
The7 multi-purpose theme have page header options where you can set a fancy header, slideshow as a page header, but these options cannot set for a dynamic page like category, archive, search etc. Using this workaround you can apply page header settings of any page to such dynamic page.
Add this new function to child theme’s functions.php
function set_dt_header_options($id) { global $post; $config = Presscore_Config::get_instance(); // Header options $prefix = '_dt_header_'; $header_title = get_post_meta( $id, "{$prefix}title", true ); $config->set( 'header_title', $header_title ); if ( in_array( $header_title, array( 'fancy', 'slideshow' ) ) ) { $header_background = get_post_meta( $id, "{$prefix}background", true ); } else { $header_background = 'normal'; } $config->set( 'header_background', $header_background ); // Fancy header options $prefix = '_dt_fancy_header_'; $config->set( 'fancy_header_title', get_post_meta( $id, "{$prefix}title", true ) ); $config->set( 'fancy_header_title_color', get_post_meta( $id, "{$prefix}title_color", true ) ); $config->set( 'fancy_header_title_aligment', get_post_meta( $id, "{$prefix}title_aligment", true ) ); $config->set( 'fancy_header_subtitle', get_post_meta( $id, "{$prefix}subtitle", true ) ); $config->set( 'fancy_header_subtitle_color', get_post_meta( $id, "{$prefix}subtitle_color", true ) ); $config->set( 'fancy_header_height', get_post_meta( $id, "{$prefix}height", true ) ); $config->set( 'fancy_header_bg_color', get_post_meta( $id, "{$prefix}bg_color", true ) ); $config->set( 'fancy_header_bg_image', get_post_meta( $id, "{$prefix}bg_image", true ) ); $config->set( 'fancy_header_bg_repeat', get_post_meta( $id, "{$prefix}bg_repeat", true ) ); $config->set( 'fancy_header_bg_position_x', get_post_meta( $id, "{$prefix}bg_position_x", true ) ); $config->set( 'fancy_header_bg_position_y', get_post_meta( $id, "{$prefix}bg_position_y", true ) ); $config->set( 'fancy_header_bg_fullscreen', get_post_meta( $id, "{$prefix}bg_fullscreen", true ) ); $config->set( 'fancy_header_bg_fixed', get_post_meta( $id, "{$prefix}bg_fixed", true ) ); $config->set( 'fancy_header_parallax_speed', floatval( get_post_meta( $id, "{$prefix}parallax_speed", true ) ) ); $config->set( 'fancy_header_height', absint( get_post_meta( $id, "{$prefix}height", true ) ) ); // Slideshow options $prefix = '_dt_slideshow_'; $config->set( 'slideshow_mode', get_post_meta( $id, "{$prefix}mode", true ) ); $config->set( 'slideshow_sliders', get_post_meta( $id, "{$prefix}sliders", false ) ); $config->set( 'slideshow_layout', get_post_meta( $id, "{$prefix}layout", true ) ); $slider_prop = get_post_meta( $id, "{$prefix}slider_proportions", true ); if ( empty($slider_prop) ) { $slider_prop = array( 'width' => 1200, 'height' => 500 ); } $config->set( 'slideshow_slider_width', $slider_prop['width'] ); $config->set( 'slideshow_slider_height', $slider_prop['height'] ); $config->set( 'slideshow_slider_scaling', get_post_meta( $id, "{$prefix}scaling", true ) ); $config->set( 'slideshow_3d_layout', get_post_meta( $id, "{$prefix}3d_layout", true ) ); $slider_3d_prop = get_post_meta( $id, "{$prefix}3d_slider_proportions", true ); if ( empty($slider_3d_prop) ) { $slider_3d_prop = array( 'width' => 500, 'height' => 500 ); } $config->set( 'slideshow_3d_slider_width', $slider_3d_prop['width'] ); $config->set( 'slideshow_3d_slider_height', $slider_3d_prop['height'] ); $config->set( 'slideshow_autoslide_interval', get_post_meta( $id, "{$prefix}autoslide_interval", true ) ); $config->set( 'slideshow_autoplay', get_post_meta( $id, "{$prefix}autoplay", true ) ); $config->set( 'slideshow_hide_captions', get_post_meta( $id, "{$prefix}hide_captions", true ) ); $config->set( 'slideshow_slides_in_raw', get_post_meta( $id, "{$prefix}slides_in_raw", true ) ); $config->set( 'slideshow_slides_in_column', get_post_meta( $id, "{$prefix}slides_in_column", true ) ); $config->set( 'slideshow_revolution_slider', get_post_meta( $id, "{$prefix}revolution_slider", true ) ); $config->set( 'slideshow_layer_slider', get_post_meta( $id, "{$prefix}layer_slider", true ) ); $config->set( 'slideshow_layer_bg_and_paddings', get_post_meta( $id, "{$prefix}layer_show_bg_and_paddings", true ) ); }
Now overwrite function presscore_fancy_header_controller() like below in child theme’s functions.php
function presscore_fancy_header_controller() { $config = Presscore_Config::get_instance(); if(is_category() || is_archive() ) { set_dt_header_options(2); } if ( 'fancy' != $config->get('header_title') ) { return; } // turn off regular titles and breadcrumbs remove_action('presscore_before_main_container', 'presscore_page_title_controller', 16); $title_color_esc = esc_attr($config->get('fancy_header_title_color')); // title and sub title $title = ''; if ( $config->get('fancy_header_title') ) { $title .= '<h1 class="fancy-title"'; if ( $title_color_esc ) $title .= ' style="color: ' . $title_color_esc . '"'; $title .= '>' . wp_kses_post( $config->get('fancy_header_title') ) . '</h1>'; } if ( $config->get('fancy_header_subtitle') ) { $title .= '<h2 class="fancy-subtitle"'; if ( $config->get('fancy_header_subtitle_color') ) $title .= ' style="color: ' . esc_attr($config->get('fancy_header_subtitle_color')) . '"'; $title .= '>' . wp_kses_post( $config->get('fancy_header_subtitle') ) . '</h2>'; } if ( $title ) { $title = '<div class="wf-td hgroup">' . $title . '</div>'; } // breadcrumbs // remove wrap from bredcrumbs $breadcrumbs = ''; if ( apply_filters( 'dt_sanitize_flag', of_get_option( 'general-show_breadcrumbs', 1 ) ) ) { remove_filter( 'presscore_get_breadcrumbs', 'presscore_add_divider_wrap_to_breadcrumbs', 15 ); $breadcrumbs = presscore_get_breadcrumbs(); add_filter( 'presscore_get_breadcrumbs', 'presscore_add_divider_wrap_to_breadcrumbs', 15 ); } // paint breadcrumbs if ( $title_color_esc ) { $breadcrumbs = str_replace('<li', '<li style="color: ' . esc_attr($title_color_esc) . ';"', $breadcrumbs); } $content = $title . $breadcrumbs; // container classes $container_classes = array( 'fancy-header' ); switch ( $config->get('fancy_header_title_aligment') ) { case 'center': $container_classes[] = 'title-center'; break; case 'right': $container_classes[] = 'title-right'; $content = $breadcrumbs . $title; break; default: $container_classes[] = 'title-left'; } $parallax_speed = $config->get('fancy_header_parallax_speed'); // parallax $data_attr = array(); if ( $parallax_speed ) { $container_classes[] = 'fancy-parallax-bg'; $data_attr[] = 'data-prlx-speed="' . $parallax_speed . '"'; } if ( !of_get_option('general-show_breadcrumbs', true) ) { $container_classes[] = 'breadcrumbs-off'; } // container style $container_style = array(); if ( $config->get('fancy_header_bg_color') ) { $container_style[] = 'background-color: ' . $config->get('fancy_header_bg_color'); } if ( $config->get('fancy_header_bg_image') ) { $image_meta = wp_get_attachment_image_src( current($config->get('fancy_header_bg_image')), 'full' ); if ( $image_meta ) { $container_style[] = "background-image: url({$image_meta[0]})"; $repeat = $config->get('fancy_header_bg_repeat'); $position_x = $config->get('fancy_header_bg_position_x'); $position_y = $config->get('fancy_header_bg_position_y'); $container_style[] = "background-repeat: {$repeat}"; $container_style[] = "background-position: {$position_x} {$position_y}"; $fullscreen = $config->get('fancy_header_bg_fullscreen'); if ( $fullscreen ) { $container_style[] = 'background-size: cover'; } if ( $config->get('fancy_header_bg_fixed') ) { $container_style[] = 'background-attachment: fixed'; } } } // header height $min_h_height = ' style="min-height: ' . $config->get('fancy_header_height') . 'px;"'; $wf_table_height = ' style="height: ' . $config->get('fancy_header_height') . 'px;"'; $container_style[] = 'min-height: ' . $config->get('fancy_header_height') . 'px'; printf( '<header id="fancy-header" class="%1$s" style="%2$s" %3$s> <div class="wf-wrap"> <div class="wf-table"%5$s>%4$s</div> </div> </header>', esc_attr( implode( ' ', $container_classes ) ), esc_attr( implode( '; ', $container_style ) ), implode( ' ', $data_attr ), $content, $wf_table_height, $min_h_height ); }
Where in line 3 is how we apply the page header settings of page id 2 for archive and category pages
if(is_category() || is_archive() ) { set_dt_header_options(2); }
Add additional condition as per your requirement
//For search page if(is_search()) { set_dt_header_options(7); } //For 404 if(is_404()) { set_dt_header_options(125); } //For a specific category, 9 is the category id if(is_category(9)) { set_dt_header_options(137); }
This workaround only tested in Older version of The7 (The7.1 – Version 4.4.7 or less), For The7.2 this options are already under the hood and can expect in coming version. Checkout here to add dynamic title in fancy header.
Happy coding!
Hi,
Especially for SEO reasons, I try to displays my description under my title for tags and categories pages.
So, I found your code and it looks to be the good way, but I’m not sure how to do it.
Actually, I would like to replace:
Tag Archives : Tag_Name
par
Tag_Name
Tag_Description displayed as subtitles fancy header
Does your code could help to do this ?
Thanks 🙂
Hi,
Pardon, not sure I got your requirement. using this code you can set fancy header/sliders to you category pages in The7 like normal pages and posts.
Thanks
Hi Safeer,
I tested your code on my local version it works very well.
But your code will get the title and the subtitles of another page, that can be useful for example for all archives pages to get title + subtitles of the blog page.
What I need to do is have this fancy header (same looking with h1 and h2 subtitles), but the content should not be the same than another page (by using ID like your code do), but by displaying the title and the description of the archive.
To give you an example :
I have a tag call Mercedes
The description of this tag is Mercedes is a german brand.
I need to have Mercedes as H1 and Mercedes is a german brand as subtitle, in the fancy header.
So I wanted to know it you think complicated to use the fancy header style but to display dynamically title and description of each archive.
THANKS 🙂
Hi,
You can either modify function presscore_fancy_header_controller to get the dynamic title or follow other article to get dynamic title in fancy header.
http://www.thecodepoetry.com/dynamic-title-in-fancy-header-the7-theme/
Hi Safeer, thanks for this guide. I am not using a child theme with my site, do I still follow the same guide for the files in the parent theme?
Hi Shannon,
Yes, you can add it in functions.php, but you have to re do the changes on each theme update.