Tagged: 

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #586683

    Hi,

    I am not wanting to display the breadcrumbs on the page and so have selected “Display only title” in the settings. However, I want to show the parent page title like so:

    Parent Page Title : Current Page Title
    ————————————————————

    I have found the function I need to amend inthe functions-enfold.php file but don’t know how to find the ID or title of the parent page. Can anyone help?

    //advanced title + breadcrumb function
    if(!function_exists('avia_title'))
    {
    	function avia_title($args = false, $id = false)
    	
    	{
    		global $avia_config;
    
    		if(!$id) $id = avia_get_the_id();
                    
                    //something like this maybe? 
    		if(!$parentID) $parentID = avia_get_the_parent_id();  
                     $page_title = get_the_title($parentID ) . ': ' . get_the_title($id),  //what do I need to amend on this line?
    
    		$header_settings = avia_header_setting();
    		if($header_settings['header_title_bar'] == 'hidden_title_bar') return "";
    		
    
    		$defaults 	 = array(
    
    			'title' 		         =>     $page_title,  
    			'subtitle' 		=> "", //avia_post_meta($id, 'subtitle'),
    			'link'			=> get_permalink($id),
    			'html'			=> "<div class='{class} title_container'><div class='container'><{heading} class='main-title entry-title'>{title}</{heading}>{additions}</div></div>",
    			'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_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'] = "";
    		}
    		
    		
    		// 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);
    
    		//disable breadcrumb if requested
    		if($header_settings['header_title_bar'] == 'title_bar') $args['breadcrumb'] = false;
    		
    		//disable title if requested
    		if($header_settings['header_title_bar'] == 'breadcrumbs_only') $args['title'] = '';
    
    		// 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) && !empty($title)) $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));
    
    		$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;
    		}
    	}
    }
    • This topic was modified 8 years, 10 months ago by lol4000.
    #587532

    Hey lol4000!

    Thank you for using Enfold.

    Use this filter in the functions.php file:

    add_filter('avf_title_args', 'avf_title_args_mod', 10, 2);
    function avf_title_args_mod($args, $id) {
    	global $post;
    	$parent = empty( $post->post_parent ) ? '' : get_the_title($post->post_parent);
        $args['title'] = $parent . ' > ' . get_the_title($id);
        return $args;
    }
    

    Regards,
    Ismael

    #590264

    Thats great, thanks so much for your help :)

    #591336

    Hi,

    Glad we could help :-)

    Thanks,
    Rikard

    #650709

    Is this possible to do without making the title setting global? For instance, can it be applied to an isolated set of child pages, consisting of only the child pages under a single specific parent page, without affecting any and all child pages throughout the site?

    Thanks!

    • This reply was modified 8 years, 6 months ago by ajarkovsky.
    #651699

    Hi,

    you would need to work with WordPress’ “is_page” conditional function: https://developer.wordpress.org/reference/functions/is_page/

    Best regards,
    Andy

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘How to display parent page title before current page title in the header’ is closed to new replies.