Two domains should point to the same website (test.domain and test2.domain). When someone visits test.domain, it should display the main logo. When someone visits test2.domain, it should display a different logo.
I am using WordPress and the free version of Elementor.
How can I achieve this?
Two domains should point to the same website (test.domain and test2.domain). When someone visits test.domain, it should display the main logo. When someone visits test2.domain, it should display a different logo.
I am using WordPress and the free version of Elementor.
How can I achieve this?
Share Improve this question asked Mar 14 at 9:42 Anto NavisAnto Navis 4210 bronze badges 1- It looks like your question could use a bit more detail. What have you tried so far? Including error messages, and relevant code snippets will help others understand your issue better and provide more useful answers. You might also want to check out How to Ask for tips on improving your question! – OverdueOrange Commented Mar 14 at 10:03
1 Answer
Reset to default 0Your question is not clear enough. There can be two cases:
Case 1: WordPress Multisite
You can enable the WordPress Multisite feature to use a different logo (or even completely different content) for different subdomains within a single WordPress installation.
Case 2: Different Logos for Subdomains in a Single WordPress Site
If you want to use the same WordPress installation (not Multisite) but display a different logo based on the subdomain, you can achieve this using CSS and JavaScript.
Step 1: Add a Custom CSS Class to the Logo
- Edit the Header Template in Elementor (where your logo is located).
- Click on the logo widget.
- Go to the Advanced tab.
- Find the CSS Classes field and add a custom class (e.g.,
custom-logo
). - Click Update to save changes.
Step 2: Add Custom JavaScript
- Go to WordPress Dashboard → Elementor → Custom Code.
- Click "Add New Custom Code".
- Enter a name (e.g., "Custom Logo Script").
- Paste the following JavaScript inside the editor.
- Set Location to Footer (better for performance).
- Click Publish and set conditions (e.g., "Entire Site").
- Click Save & Close.
Custom JavaScript Code
document.addEventListener("DOMContentLoaded", function () {
let logo = document.querySelector(".custom-logo img"); // Target logo
if (!logo) return; // Exit if logo not found
let host = window.location.hostname; // Get subdomain
if (host === "test2.domain") {
logo.src = "https://your-site/wp-content/uploads/alternate-logo.png"; // Change logo for test2
} else {
logo.src = "https://your-site/wp-content/uploads/main-logo.png"; // Default logo
}
});