Enjoy unlimited access to all forum features for FREE! Optional upgrade available for extra perks.

different sidebar to what domain is in the URL

Status
Not open for further replies.

Paullas

Staff member
Joined
Jul 13, 2004
Posts
5,791
Reaction score
336
Hi

Can anyone think of an idea or way where i park say 50 domains on a wordpress site i can show a different sidebar to what domain name is in the URL?

thanks in advance

paul
 
Themes call get_sidebar() which loads sidebar.php, which then loads the widgets assigned to the sidebar through the dynamic_sidebar('widget-area') function. Each widget area is defined in the theme functions.php file.

Different ways to approach it:

50 sidebar files e.g. sidebar-domain1.php and change the get_sidebar() call to get_sidebar(domain-1) - through capturing the domain via the url, and then widgets assigned to the sidebar in WP admin. Long winded, same widgets.

One sidebar and register a widget area per domain via register_sidebar() in your functions.php file. Messy.

One alternative is to bypass widgets and keep the get_sidebar() call, but in the sidebar use an include file with html / php to created the content e.g. include( 'domain1.php') depending on the domain in the url.

This could be enhanced by creating a post-type called domain and then creating a single-domain.php template file which could be used to select an include file. e.g. /domain/domain1

You could do it via a taxonomy as well, and capture the term for the include. The file you would use would be taxonomy-domain.php

The Woosidebars plugin can automate a bit of it if you want the multiple widget areas route. Create a domain taxonomy and a term for each domain and then create a 'new' widget area per term and override the default sidebar. Still messy, you'd end up with a sidebar area per domain in the WP admin area. Still, workable.
S
 
Last edited:
hi alex

i have just added them in cpanel and parked them on the main domain.

It is my understanding that WordPress requires an install for each domain because of the way the URL structure works. Wouldn't most people therefore use WordPress multi site with a single theme and point the parked domains at the sub-sites? You could then set up the individual sidebars.

tifosi's suggestions are correct, but assume any single install can handle the multiple domains. If I am correct in thinking you can't then the options are to either go down the multi site route, or have a single central domain with the other domains set as parameters. You can then use that parameter to select the relevent registered sidebar. Parameters themselves are not SEO friendlt, but then again neither is a single page site.
 
If all you're wanting to change is the sidebar content then multi-site approach is a bit of overkill.

WP is pretty good at grabbing query vars, though you'd have to register a new one for 'd'. You can then do what you want with it. Using a registered taxonomy and grabbing the term would bypass that, and you'd be easily able to permalink it.
 
If all you're wanting to change is the sidebar content then multi-site approach is a bit of overkill.

WP is pretty good at grabbing query vars, though you'd have to register a new one for 'd'. You can then do what you want with it. Using a registered taxonomy and grabbing the term would bypass that, and you'd be easily able to permalink it.

I appreciate that, and agree with you.

My query is whether say www.example.com and www.example2.com and www.example3.com etc rendering the same WP install will actually work which is what I think the OP is after?
 
Last edited:
It'd be much easier to advise on the best solution for doing this if we knew what the sidebar contained and how much it differed site to site.
 
sorry i should explain more what i am doing, basically i want to park my domains on 1 WP domain and then use different sidebar with products/banners then have a form on the page so basically just trying to monetise my parked domains better.
 
Might be better to do it by category then.

Post Type: Domain
Taxonomy: Category

Add domain to post type, assign to category. Use woosidebars to generate a 'category' sidebar per category and assign to category term and override the default sidebar. 10+ category sidebars with their own widgets e.g text widgets with products. Should work.
 
Might be better to do it by category then.

Post Type: Domain
Taxonomy: Category

Add domain to post type, assign to category. Use woosidebars to generate a 'category' sidebar per category and assign to category term and override the default sidebar. 10+ category sidebars with their own widgets e.g text widgets with products. Should work.

Probably a better question for Paul, but am I missing something?

Let's say he has example.com, example.org and example.co.uk. If he wants people to go to either of these domains and the page rendered is the homepage for that domain, ie that domain is exactly what is in the address bar, then how can this be done with 1 WordPress install? A single WP install can only work with a single domain. Changing the domain breaks the WP structure.

I hope I'm wrong mind, because this would seriously help us with a project we're working on at the minute ;)

But what you suggest tifosi, in my mind, only works if the original domain forwards to a single central domain with the WP install. Now this could be what Paul wants and I've misunderstood, but my impression was that the domain wouldn't forward, it would instead render the instance of WP as its own site defined by the fact the domain doesn't change in any way.

I can only see this working as either some parameter or sub directory that defines the domain following a redirect, or by multisite where one WP install allows multiple domains to render on a single install.
 
Last edited:
There are a load of $10 scripts that allow one Wordpress install to show the parked domains and in the url bar. Don't you just then have some html in the sidebar which displays your products based upon the url?

If host equals etc your keyword. A couple of lines could work for dozens of domains and different keywords products etc

Or is that too easy?
 
There are a load of $10 scripts that allow one Wordpress install to show the parked domains and in the url bar. Don't you just then have some html in the sidebar which displays your products based upon the url?

If host equals etc your keyword. A couple of lines could work for dozens of domains and different keywords products etc

Or is that too easy?

No its not that easy.
 
Probably a better question for Paul, but am I missing something?

Let's say he has example.com, example.org and example.co.uk. If he wants people to go to either of these domains and the page rendered is the homepage for that domain, ie that domain is exactly what is in the address bar, then how can this be done with 1 WordPress install? A single WP install can only work with a single domain. Changing the domain breaks the WP structure.

I hope I'm wrong mind, because this would seriously help us with a project we're working on at the minute ;)

But what you suggest tifosi, in my mind, only works if the original domain forwards to a single central domain with the WP install. Now this could be what Paul wants and I've misunderstood, but my impression was that the domain wouldn't forward, it would instead render the instance of WP as its own site defined by the fact the domain doesn't change in any way.

I can only see this working as either some parameter or sub directory that defines the domain following a redirect, or by multisite where one WP install allows multiple domains to render on a single install.

What i am after is each domain will stay in the URL i have all that working but what i then want to be able to do is display different sidebars or footer bars which will have php in them to pull products from a database.

I will reply to your PM
 
Do you actually need different sidebars or just the sidebar to display different content.

Code:
function check_input($data)
{
    $data = htmlspecialchars($data);
    return $data;
}
//Get Page URL
function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return check_input($pageURL);
}
$url = curPageURL();
$url = str_replace('http://www.','', $url);
$url = str_replace('/','', $url);

If you make URL table with all the urls, category, keyword sidebarname etc in your database you could add pull a sidebar based on info stored in the table
But do you really want to have tons of sidebars I'd just have a url table with the data

Then in my sidebar code select from url tbles where url = $url get the category keyword or whatever then populate you products based on this
 
Status
Not open for further replies.

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Featured Services

Sedo - it.com Premiums

IT.com

Premium Members

AucDom
UKBackorder
Be a Squirrel
Acorn Domains Merch
MariaBuy Marketplace

Domain Forum Friends

Other domain-related communities we can recommend.

Our Mods' Businesses

Perfect
Service
Laskos
*the exceptional businesses of our esteemed moderators
Top Bottom