Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • #743588

    How can i have different logos with different link for specific pages and their subpages, categories and their subcategories and their posts ?

    #743773

    Hey KyriakosKaz,

    There’s nothing like that in the theme by default unfortunately. You will have to find a third party plugin or custom code to be able to implement that type of functionality.

    Best regards,
    Rikard

    #743877

    this might help:
    (Example page-id is 2854)

    add_filter('avf_logo','av_change_logo');
    function av_change_logo($logo)
    {
        if( is_page(2854) ) {
    		$logo = "/wp-content/uploads/logo1.png";
    	}
        return $logo;
    }
    
    add_filter('avf_logo_link','av_change_logo_url');
    function av_change_logo_url($url)
    {
    	if( is_page(2854) ) {
           return "link url here";
    	}
    }

    is there a possibility to combine these rules ? Rikard

    btw. you can insert here every conditional tag you know even arrays:
    f.e.

    add_filter('avf_logo','av_change_logo');
    function av_change_logo($logo)
    {
        if( is_page( array( 42, 54, 6 ) ) ){
    		$logo = "/wp-content/uploads/logo1.png";
    	}
        return $logo;
    }
    
    add_filter('avf_logo_link','av_change_logo_url');
    function av_change_logo_url($url)
    {
    	if( is_page( array( 42, 54, 6 ) ) ){
           return "link url here";
    	}
    }

    if ( is_singular( 'event' ) || is_search() || is_category() || is_page() && !is_page(1307) || is_singular( 'portfolio' ) )
    etc pp works all

    #743882

    Hi!

    Please refer to @guenni007’s post above

    @guenni007
    Thanks! :)

    Cheers!
    Yigit

    #743899

    btw:

    Note: There is no function to check if a page is a sub-page in wordpress codex – but
    we can get around the problem if we make a new function :

    function is_tree($pid) {   
    	global $post;       
    		if(is_page()&&($post->post_parent==$pid||is_page($pid))) 
                   return true;
    		else 
                   return false;
    };

    than you can use it like:

    than we can use conditional tag if it is page id 2 or is subpage of page id 2

    if (is_tree(2)) {
      do something
    }

    PS : only works with one level it does not check if a page is sub sub page !!!

    #743911

    ah sorry i didn’t mention it above – these codes are for child-theme functions.php !

    #745320

    Either it is not so important or you changed it and you forgot to response or it is to complicated . So if we had input we can clarify those settings

    #745363

    Hi,

    Let us wait to hear from the creator of the thread :)

    Best regards,
    Yigit

    #758011

    I have a similar need to combine these rules.

    So is the following a proper syntax to have the logo show up on page 483 and on all posts under the category music, it doesn’t seem to work for me?

    add_filter('avf_logo','av_change_logo');
    function av_change_logo($logo)
    {
        if(is_page(483) || is_category('music') )  {
        $logo = "/wp-content/uploads/2015/12/music-horiz.png";
        }
        return $logo;
    }
    
    add_filter('avf_logo_link','av_change_logo_link');
    function av_change_logo_link($link)
    {
        if(is_page(483) || is_category('music') ){
        $link = "/music/";
        }
        return $link;
    }
    #758018

    if you have full ftp access there was no risc to test yourself.
    If it crashes – redo changings via ftp ( by erasing new rules)

    don’t know if relative path is ok – but it looks good to me

    #758046

    Thank you Guenni007

    I did try it, but the code only replaces the logo on the page 483, however it does not replace the logo on the category

    #758560

    be careful it replaces it on category view
    if you have single post with that category you have to take a different conditional tag

    try than with has_category(‘music’)

    btw – i think if you only set the parameter to has_category the is_category is included

    #759226

    Thank you so much “has” was the answer!

    #760622

    Hi bluelotus,

    Please let us know if you have any more questions regarding this issue or we can close it.

    Best regards,
    Victoria

    #760834

    All set!

    Thank you all for your help.

    For reference, the code that worked is:

    add_filter('avf_logo','av_change_logo');
    function av_change_logo($logo)
    {
        if(is_page(483) || has_category('music') )  {
        $logo = "/wp-content/uploads/2016/12/music-horiz.png";
        }
        return $logo;
    }
    
    add_filter('avf_logo_link','av_change_logo_link');
    function av_change_logo_link($link)
    {
        if(is_page(483) || has_category('music') ){
        $link = "/music/";
        }
        return $link;
    }
    #760842

    Hi!

    Glad you figured it out and thanks for sharing your solution.
    Let us know if you have any other questions or issues :)

    Cheers!
    Yigit

Viewing 16 posts - 1 through 16 (of 16 total)
  • The topic ‘Different logos for different pages/categories’ is closed to new replies.