Is that the real URL (mysite1.com, mysite2.com) or can you give us a link to the real one?
Bigger picture questions:
Are you trying to have two sites that mirror one another? WordPress is not set up that way. It is possible to use the same database on two sites (called multisite), but not the same tables within that database (for example, the wp_posts table that stores all the data from posts/pages) on two different sites.
In order to have the same posts show up on two different sites (a questionable practice in terms of search engine optimization anyways) you have to have two databases that mirror one another. (and that’s extremely high-level code that we cant help with on these forums)
Does that make sense?
hi Meredith , actualy i’m working on localhost
I want my two different sites to display same posts .
is that really extremely high-level code ?
I’d like to know why you want both sites to have the same content?
It’s been discussed many times on here, and on pretty much every other web/SEO board around, that two sites with the same content will be penalised or dropped completely by Google, so you’ll get no search traffic at all – ever.
This may or may not by a concern for you, but it’s a very big concern for most webmasters out there.
One of the nice things about WordPress is the great number of hooks in the code allowing you to extend or override core functionality.
One way to approach this problem would be to set an Apache environment variable in your vhost file for each site that could be used in the WordPress bootstrap process to over-ride the theme and base URL setup.
e.g. in Apache vhost add:
SetEnv WP_CONTEXT main
and
SetEnv WP_CONTEXT mobile
(or equivalent if you’re using a different webserver).
In wp-config.php:
switch ($_SERVER['WP_CONTEXT']) {
case 'main':
define('WP_HOME','http://maindomain.com');
define('WP_SITEURL','http://maindomain.com');
break;
case 'mobile':
define('WP_HOME','http://mobile.maindomain.com');
define('WP_SITEURL','http://mobile.maindomain.com');
break;
}
This will set the base URLs based on the environment variable.
Then in plugin add the following filters:
add_filter('template', 'change_theme');
add_filter('option_template', 'change_theme');
add_filter('option_stylesheet', 'change_theme');
function change_theme()
{
switch ($_SERVER['WP_CONTEXT']) {
case 'main':
return 'main';
break;
case 'mobile':
return 'mobile';
break;
}
This needs to be in a plugin so that it’s loaded before the normal theme loading process (functions.php is part of the theme and hence too late). These filters will intercept and over-ride the theme settings from the database.
is it working for 2 différent website with the same database?
The biggest problem with running two sites off the same database with the same content is that all of the links and images in your posts/pages are hard-coded ot the domain that they are uploaded/inserted by. This means that if you insert a link to a page, it goes t othe page on that site only, and it will never link to the same page on the second site.
And again, why do you want two different sites with the same content?
I have two facebook page with two different names, I want to use them for selling my products
I can edit/change single.php for each website , i’am ussing custom post types
What prevents you from selling the product on the two facebook accounts (which is weird and shady, by the way) but using the same WordPress website?
Are you pretending to be two completely different people selling the same products?
There are so many confusing things about this whole scenario.
The short answer is that you’ll be hacking core code, which is frowned upon here for many reasons, and whatever gain you get by “streamlining” your two websites will certainly be lost in terms of SEO and general don’t-be-a-scammer web etiquette.
Afraid I can’t help with that.
SEO is not my problem guys ):
So basically a multi-site type of thing? wpmudev has a plugin for that but it cost money https://premium.wpmudev.org/project/multisite-content-copier/
hi mon3 ,nah this is about multisite but thx anyway