Tagged: ,

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #213734

    Hey guys, you already solved this issue for me, except I had to make a couple of changes. As such, your great answers do not apply any more. The thread was closed to replies, and I updated the last post with the problem, but I wanted to make sure you saw it. I am positive this is a quick fix. See the last (edited) post in this thread: https://kriesi.at/support/topic/rename-blog-title-and-breadcrumb/

    Thanks again,

    Chris

    #214336

    Hi Imburr!

    Please insert this code into your functions.php file

    
    if(!function_exists('avia_modify_blog_breadcrumb'))
    {
    	add_filter('avia_breadcrumbs_trail','avia_modify_blog_breadcrumb');
    
    	function avia_modify_blog_breadcrumb($trail)
    	{
    		if(get_post_type() === "post" && (is_single() || is_category() || is_archive() || is_tag()))
    		{
    			$blogid = 20;
    			if($blogid)
    			{
    				$blog = '<a href="' . get_permalink( $blogid ) . '" title="' . esc_attr( get_the_title( $blogid ) ) . '">' . get_the_title( $blogid ) . '</a>';
    				array_splice($trail, 1, 0, array($blog));
    			}
    
    		}
    
    		return $trail;
    	}
    }
    

    and replace 20 with the id of your blog page.

    Best regards,
    Peter

    #214466

    I know this line of code is painful for you guys, and I apologize for being so dense. Your code works, but when I also add my other code to rename the breadcrumb it does not work. Here is the code I have now:

    
    if(!function_exists('avia_modify_blog_breadcrumb'))
    {
        function avia_modify_blog_breadcrumb($trail)
        {
    
        	if(get_post_type() === "post" && (is_single() || is_category() || is_archive() || is_tag()))
    		{
    			$blogid = 1010;
    			if($blogid)
    			{
    				$blog = '<a href="' . get_permalink( $blogid ) . '" title="' . esc_attr( get_the_title( $blogid ) ) . '">' . get_the_title( $blogid ) . '</a>';
    				array_splice($trail, 1, 0, array($blog));
    			}
    
    		}
    
            foreach($trail as $key => $data)
            {
                    $search = 'SEO Tools to Equip Your Business & #8211; Blog';
                    if(strpos($data, $search) !== false)
                    {
                                      $data = str_replace($search, "Blog", $data);
                                      $trail[$key] = $data;
                    }
            }
            return $trail;
        }
    
        add_filter('avia_breadcrumbs_trail','avia_modify_blog_breadcrumb');
    }
    

    This is a combination of both your above fix and the fix from the other thread which renames the blog breadcrumb title to “Blog”, and does not work. The end goal is to have the blog breadcrumb to be “You Are Here: Home / Blog” and a blog post to be “You Are Here: Home / Blog / Post Title Goes Here”. I hope this makes sense, and thanks for all of the help with this. A really neat feature would be a meta field box inside of the theme where you could manually set the breadcrumb text for each post. I used another theme recently that had that feature, maybe it was Jupiter or something.

    #214777

    Hey!

    Tbh it doesn’t make sense to combine both – use this code instead which is more efficient:

    
    if(!function_exists('avia_modify_blog_breadcrumb'))
    {
        function avia_modify_blog_breadcrumb($trail)
        {
    
        	if(get_post_type() === "post" && (is_single() || is_category() || is_archive() || is_tag()))
    		{
    			$blogid = 1010;
    			if($blogid)
    			{
    				$blog = '<a href="' . get_permalink( $blogid ) . '" title="Blog">Blog</a>';
    				array_splice($trail, 1, 0, array($blog));
    			}
    
    		}
    
            return $trail;
        }
    
        add_filter('avia_breadcrumbs_trail','avia_modify_blog_breadcrumb');
    }
    

    Best regards,
    Peter

    #214848

    Ok, I did as you suggested and separated them back out then used your code. It pretty much works as intended, though the blog page itself still shows the full blog title in the breadcrumb- not a big deal, and I can live with it. Thanks for all of the work on this, was a huge help.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Breadcrumb and Blog Title formatting’ is closed to new replies.