Hi folks, I’m a little bit stuck with a problem on website I will come up with and wanted to ask how to solve the problem.
The thing is, that I have a nice working newspaper theme website with the domain “examplesite.com”. Now I have got another domain “examplesite2.com”. “examplesite2.com” is forwarding to a page from “examplesite.com” (“examplesite.com/examplepage”) and now there comes the question.
I want to show the visitors a different websitelogo if they are visiting “examplesite2.com” or (“examplesite.com/examplepage”). Further on examplepage there will be posts. So I need the head and logo design from “examplesite2.com” for a single post as well as for the category view.
Is this possible?
I don’t want to install and maintain a new wordpress with another Newspaper theme to realize that, because it is just a little subcategory/subpage from the mainsite.
Hey ho,
thanks for your reply….
I think I just have figured out a kind of solution for me.
I added some lines of code in the themes functions.php to trigger a little javascript file to change the websites logo then I am visiting the desired page or watching a post of the catgory, where the website logo should be different. Basicly the code is from codex.wordpress.org
function load_js_assets() {
if( in_category( 14 ) or is_page( 178 )) {
wp_enqueue_script('my-js', 'https://localhost/path-to-script/lchange.js', array('jquery'), '', false);
}
}
add_action('wp_enqueue_scripts', 'load_js_assets');
The thing is that the script works mostly fine but it’s way to slow. When I am visiting a desired page the script has to wait until the wrong headerlogo is loaded otherwise it wouldn’t change the logo at all.
Now my idea was is it possible to already influence the functions.php file to get the right headerlogo If I am visiting a certain page, or viewing a specific post?
I am not fit either in PHP or JS. But can you give me a hint how I can influence the theme to get the right headerlogo when I am visiting a certain page or post?
PS: I am using header-style-10
Thanks in advance
Hi,
Maybe that could be done with a condition in the header style template, you could do it in a child theme. Something like this for example would work
– https://www.screencast.com/t/FKFhhEMskitH
That would display an image from the media library in certain post pages and pages (with that condition).
Thanks
Hey ho again…
Thanks for all of your help.
The solution with the childtheme and the modified header-style.php is working flawlessly. I got the changing header logo for the is_page and the is in_category function (With 4 different logos).
But there is still a little problem with that. The thing is that there are some posts, who are in multiple categories. For example category1 (with headerlogo 1) and category2 (with headerlogo 2).
If I visit for example a page or a category page where the posts are, the logo is doing just fine, but if I click on a post and want to view the single post, the head always shows the headerlogo1 of category1 (I guess it has something to do with the alphabetical order of my categories).
Headerlogo1 in this case isn’t wrong, because the post is in this category as well.
But when I am visiting category2 and click on a post I want to have the head showing headerlogo2 and not headerlogo1.
I hope you’ll get my point.
How can I influence the headerstyle, that wordpress knows from which page I am coming from and displays the correct logo?
Is this possible at all?
Thanks in advance