I want to use, same database, (content / users / comments / meta's / categories etc.) for another wordpress install in my sub directory.
I actually want to create mobile version of my site. But i dont want to use, any mobile detect script ory css3 media queries. Just want to create my new theme (for mobile version)
For example;
the main domain has also sub domain like ;
maindomain.com // root
mobile.maindomain.com // sub directory
How this could be possible ?
You cant do that directly, as WP stores its url in database. AFAIK there is a way to "link" tables in sql, so it might be the way - link everything beside wp_options for example, but still it is a tricky way.
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:
and
(or equivalent if you're using a different webserver).
In wp-config.php:
This will set the base URLs based on the environment variable.
Then in plugin add the following filters:
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.