Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1062210

    Hi,

    Sorry, I know this has been brought up before (different headers for different parts of the site), but it is really just the logo I want different, so not the menu etc.

    I wasn’t sure if there is a simple way to achieve this.

    I have one main logo for the site (Eg. MyLogo), and then there is a subsection of the site I want to change the logo slightly to reflect that area of the business (EG. MyLogoSubArea).

    Does anyone know the easiest way to do this? I’m fairly comfortable getting into the WP templates – but would like to avoid this if there is a way to do it through the admin area.

    One of the main sections does use a CPT I’ve added, so I did wonder if I could just drop a new version of single.php into my child theme (eg single-MyCpt.php) and link it to a new header, but with enfold I can see the header.php doesn’t have a clear “logo” area, with you having to go into helper-main-menu.php and it looks to get messy and I worry to **** it up!

    Any advice would be much appreciated. We basically have a main logo, and then there is a green, blue and orange version with slightly different wording on it for different sections. I wondered if there is a way I can just change an ID on certain pages and allow it to load a different logo?

    Many thanks in advance!

    #1062343

    Hey Alexander,
    Please try this solution let us know if you want some help customizing it for your site.

    Best regards,
    Mike

    #1062414

    Thanks Mike – I will give that a go! Just one question – is it possible with that code to specify any sub pages of a specific page?

    So something like:

    add_filter('avf_logo','av_change_logo');
    function av_change_logo($logo)
    {
        if(is_page(632) [or sub pages of this page??] )
        {
        $logo = "http://kriesi.at/wp-content/themes/kriesi/images/logo.png";
        }
        return $logo;
    }

    Thanks, Alex

    #1062416

    Hi,
    To change the logo for a page and all of it’s children, Try adding this code to the end of your functions.php file in Appearance > Editor:

    //change the logo for page and all child pages 
    //first is the function to find all child pages
    function is_tree($pid)
    {
      global $post;
    
      $ancestors = get_post_ancestors($post->$pid);
      $root = count($ancestors) - 1;
      $parent = $ancestors[$root];
    
      if(is_page() && (is_page($pid) || $post->post_parent == $pid || in_array($pid, $ancestors)))
      {
        return true;
      }
      else
      {
        return false;
      }
    };
    //second is the function to change the logo, note the "is_tree"
    add_filter('avf_logo','av_change_logo');
    function av_change_logo($logo)
    {
        if (is_tree(1406)) 
    {
    	$logo = "https://kriesi.at/themes/enfold-minimal-portfolio/wp-content/uploads/sites/51/2015/07/logo_minimal_portfolio.png";
    }
    
        return $logo;
    }

    adjust to suit.

    Best regards,
    Mike

    #1062701

    Thank you Mike!

    That looks to be working well – stupidly I realised one section were not child pages, but I’d manually added into the menu a load of custom post type pages, but I adjusted your code like this:

    if (is_tree(515) or is_singular('procurement-pages'))

    And that appears to work. I still need to sort the other pages, but I feel like I’m making progress now – thank you!

    #1062733

    does “or” realy works ?
    if not try: ||

    if(is_tree(515) || is_singular('procurement-pages'))

    #1062944

    Hi,

    @alsterb
    glad to hear, we will leave this open to hear back from you that it’s solved.


    @Guenni007
    thanks for the suggestion.

    Best regards,
    Mike

    #1065071

    Hi Guenn – ‘OR’ has been working okay for me, but as per your suggestion I’ve changed it to:
    ||
    as this looks to be more standard?!

    For anyone else in the same situation, this is the final code I have that accounts for logos related to other parent pages and their sub-pages if that makes sense!:

    //change the logo for page and all child pages 
    //first is the function to find all child pages
    function is_tree($pid)
    {
     global $post;
    
     $ancestors = get_post_ancestors($post->$pid);
     $root = count($ancestors) - 1;
     $parent = $ancestors[$root];
    
     if(is_page() && (is_page($pid) || $post->post_parent == $pid || in_array($pid, $ancestors)))
     {
       return true;
     }
     else
     {
       return false;
     }
    };
    //second is the function to change the logo, note the "is_tree"
    add_filter('avf_logo','av_change_logo');
    function av_change_logo($logo)
    {
       if (is_tree(515) || is_singular('procurement-pages')) 
    {
    	$logo = "[logo url]";
    }
       elseif (is_tree(509)) 
    {
    	$logo = "[logo url]";
    }
    	elseif (is_tree(530)) 
    {
    	$logo = "[logo url]";
    }
    
       return $logo;
    }

    Obviously you would swap [logo url] for your logo url, and the numbers such as ‘530’ would need to reflect the page id of the parent page. Thanks again to Mike for his help with this!

    • This reply was modified 5 years, 10 months ago by alsterb.
    #1065162

    Hi,
    Glad we were able to help, and thanks for sharing your solution it should help others with their customization to see examples. We will close this now. Thank you for using Enfold.

    For your information, you can take a look at Enfold documentation here
    For any other questions or issues, feel free to start new threads under Enfold sub forum and we will gladly try to help you :)

    Best regards,
    Mike

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Different header logo for different sections of website’ is closed to new replies.