yanknudtskov
12/17/2016 - 1:42 PM

Add Title and breadcrumbs above content

Add Title and breadcrumbs above content

<?php

/**
	 * Modify and Override Avia Title Function to output H1
	 */
	if(!function_exists('avia_title')) {
		function avia_title($args = false, $id = false) {
			global $avia_config;

			if(is_woocommerce())
			{
				$args['title'] = get_the_title( get_the_ID() );
				$args['link'] = '';
			}

			if(!$id) $id = avia_get_the_id();

			$header_settings = avia_header_setting();
			if($header_settings['header_title_bar'] == 'hidden_title_bar') return "";

			$defaults = array(
				'title' 		=> get_the_title($id),
				'subtitle' 		=> "", //avia_post_meta($id, 'subtitle'),
				'link'			=> get_permalink($id),
				'class'			=> 'stretch_full container_wrap alternate_color '.avia_is_dark_bg('alternate_color', true),
				'breadcrumb'	=> true,
				'additions'		=> "",
				'heading'		=> 'h1' //headings are set based on this article: http://yoast.com/blog-headings-structure/
			);

			if( is_product() ) {
				$defaults['html'] = "<div class='{class} title_container'><div class='container'></div></div>".
				"<div class='{class} title_container'><div class='container'>{additions}</div></div>";
			} else {
				$defaults['html'] = "<div class='{class} title_container'><div class='container'></div></div>".
				"<div class='{class} title_container'><div class='container'><{heading} class='main-title entry-title'>{title}</{heading}>{additions}</div></div>";
			}

			if ( is_tax() || is_category() || is_tag() )
			{
				global $wp_query;

				$term = $wp_query->get_queried_object();
				$defaults['link'] = get_term_link( $term );
			}
			else if(is_archive())
			{
				$defaults['link'] = "";
			}

			//disable breadcrumb if requested
			if($header_settings['header_title_bar'] == 'title_bar') $defaults['breadcrumb'] = false;

			// Parse incomming $args into an array and merge it with $defaults
			$args = wp_parse_args( $args, $defaults );
			$args = apply_filters('avf_title_args', $args, $id);

			// OPTIONAL: Declare each item in $args as its own variable i.e. $type, $before.
			extract( $args, EXTR_SKIP );

			if(empty($title)) $class .= " empty_title ";
	        $markup = avia_markup_helper(array('context' => 'avia_title','echo'=>false));
			if(!empty($link)) $title = "<a href='".$link."' rel='bookmark' title='".__('Permanent Link:','avia_framework')." ".esc_attr( $title )."' $markup>".$title."</a>";
			if(!empty($subtitle)) $additions .= "<div class='title_meta meta-color'>".wpautop($subtitle)."</div>";
			if($breadcrumb) $additions .= avia_breadcrumbs( array( 'separator' => '/', 'richsnippet' => true, 'show_home' => false ));

			$html = str_replace('{class}', $class, $html);
			$html = str_replace('{title}', $title, $html);
			$html = str_replace('{additions}', $additions, $html);
			$html = str_replace('{heading}', $heading, $html);


			if(!empty($avia_config['slide_output']) && !avia_is_dynamic_template($id) && !avia_is_overview())
			{
				$avia_config['small_title'] = $title;
			}
			else
			{
				return $html;
			}
		}
	}

	function yanco_woocommerce_before_main_content() {
		global $avia_config;

		if(!isset($avia_config['shop_overview_column'])) $avia_config['shop_overview_column'] = "auto";

		$id = get_option('woocommerce_shop_page_id');
		$layout = get_post_meta($id, 'layout', true);

		if(!empty($layout))
		{
	        	$avia_config['layout']['current'] = $avia_config['layout'][$layout];
	        	$avia_config['layout']['current']['main'] = $layout;
		}

	    	$avia_config['layout'] = apply_filters('avia_layout_filter', $avia_config['layout'], $id);

		$title_args = array();

		if(is_woocommerce())
		{
			$t_link = "";

			if(is_shop()) $title  = get_option('woocommerce_shop_page_title');

			$shop_id = woocommerce_get_page_id('shop');
			if($shop_id && $shop_id != -1)
			{
				if(empty($title)) $title = get_the_title($shop_id);
				$t_link = get_permalink($shop_id);
			}

			if(empty($title)) $title  = __("Shop",'avia_framework');

			if(is_product_category() || is_product_tag())
	        {
	            global $wp_query;
	            $tax = $wp_query->get_queried_object();
	            $title = $tax->name;
	            $t_link = '';
	        }

			$title_args = array('title' => $title, 'link' => $t_link);
		}

		if( get_post_meta(get_the_ID(), 'header', true) != 'no') echo avia_title($title_args);

		if( is_archive() ) {
			$avia_config['shop_overview_column'] = 3;
		}

		if( is_product() ) {
			$avia_config['shop_overview_column'] = 4;
		}

		echo "<div class='container_wrap container_wrap_first main_color ".avia_layout_class( 'main' , false )." template-shop shop_columns_".$avia_config['shop_overview_column']."'>";

			echo "<div class='container'>";

			if(!is_singular()) { $avia_config['overview'] = true; }
	}