-
AuthorPosts
-
February 6, 2017 at 8:48 pm #743588
How can i have different logos with different link for specific pages and their subpages, categories and their subcategories and their posts ?
February 7, 2017 at 10:04 am #743773Hey 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,
RikardFebruary 7, 2017 at 1:08 pm #743877this 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 allFebruary 7, 2017 at 1:16 pm #743882February 7, 2017 at 1:44 pm #743899btw:
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 !!!
February 7, 2017 at 2:05 pm #743911ah sorry i didn’t mention it above – these codes are for child-theme functions.php !
February 10, 2017 at 11:12 am #745320Either 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
February 10, 2017 at 12:38 pm #745363March 8, 2017 at 8:31 pm #758011I 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; }
March 8, 2017 at 8:45 pm #758018if 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
March 8, 2017 at 9:52 pm #758046Thank 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
March 9, 2017 at 9:14 pm #758560be careful it replaces it on category view
if you have single post with that category you have to take a different conditional tagtry than with has_category(‘music’)
btw – i think if you only set the parameter to has_category the is_category is included
March 11, 2017 at 3:06 am #759226Thank you so much “has” was the answer!
March 14, 2017 at 11:50 am #760622Hi bluelotus,
Please let us know if you have any more questions regarding this issue or we can close it.
Best regards,
VictoriaMarch 14, 2017 at 4:45 pm #760834All 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; }
March 14, 2017 at 4:52 pm #760842 -
AuthorPosts
- The topic ‘Different logos for different pages/categories’ is closed to new replies.