Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: BBPress Forums to Subdomain (included with domain)

@inspirationally

Participant

I just installed my forum at http://mydomain.com/forums, which is the same as http://myseconddomain.com/forums – and used

1. the multidomain plugin https://wordpress.org/plugins/multidomain/

2. templates and menus based on the domain you see – this includes a different index loop file and different custom menu.

This also works with subdomains.

Here the code of index.php:

<?php
/**
 * The main template file.
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query. 
 * E.g., it puts together the home page when no home.php file exists.
 * Learn more: https://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage Twenty_Ten
 * @since Twenty Ten 1.0
 */

get_header(); ?>

<?php if ( $_SERVER['SERVER_NAME'] == 'mydomain.com' ) { ?>

			<?php
			/* Run the loop to output the posts.
			 * If you want to overload this in a child theme then include a file
			 * called loop-index.php and that will be used instead.
			 */

			 get_template_part( 'loop', 'index-mydomain' );
			?>
<?php } elseif ( $_SERVER['SERVER_NAME'] == 'myseconddomain.com' || $_SERVER['SERVER_NAME'] == 'sub.mydomain.com'  ) { ?>

			<?php
			/* Run the loop to output the posts.
			 * If you want to overload this in a child theme then include a file
			 * called loop-index.php and that will be used instead.
			 */

			 get_template_part( 'loop', 'index-myseconddomain' );
			?>			
<?php } ?>

<?php get_sidebar(); ?>
<?php get_footer(); ?>

Then there is loop for the main site, and one for the forum including the forum overview.

In the header I have

<?php if ( $_SERVER['SERVER_NAME'] == 'mydomain.com ) { ?>
<?php wp_nav_menu( array('container_class' => 'menu','menu' => 'Mydomain.org' )); ?>
<?php } elseif ( $_SERVER['SERVER_NAME'] == 'myseconddomain.com' || $_SERVER['SERVER_NAME'] == 'sub.mydomain.com'  ) { ?>
<?php wp_nav_menu( array('container_class' => 'menu','menu' => 'Myseconddomain.com' )); ?>
<?php } ?>

(the same for sidebar widgets etc.)

Of course you could work with special forum templates for the forum sites.

(real example see johnny-depp.org/deppheads.com)

I think, I will have to add some kind of rewrite to not have duplicate content in the future.

Skip to toolbar