• Resolved C8H10N4O2

    (@c8h10n4o2)


    Hi,

    I’m setting up a website with WordPress for the site/blog part and FluxBB for the forum part. The site adress is https://bitcoin-fr.org/

    I’m currently trying to integrate FluxBB into WordPress (graphically, at the moment).

    I’ve set up a subdomain (https://forum.bitcoin-fr.org/) for the forum and i’ve used get_header() and get_footer() to bring the WordPress feel to the forum page.

    My setup is as folow :

    root/
       forum/
       wp-admin/
       wp-content/
       ...
       index.php

    As you can see on the site, all is looking good but for some reason, the is_home() test in some part of my header.php return true also on the forum index page.

    For example, you can see that the Home link at the top of the site is in bold whereas it should be in bold only in the WordPress home.

    Strangely, navigating in the forum makes the “home” link normal again, meaning that is_home() returns false (wich is what should also happen on the forum index page). I don’t know what to think about that.

    Any idea ? Maybe it’s an incompatibility between WP and FluxBB ? Where do I start to search ? WordPress ? FluxBB ? My WordPress template ?

    Thanks !

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter C8H10N4O2

    (@c8h10n4o2)

    From what I understand at the moment :

    is_home use the WordPress Query API to know if the page is the home or not.

    If there is no query, as for the forum index page, is_home() will return true.

    By navigating in the forum, you append things to the URL i.e. you set a query so is_home returns false.

    Anyway, the quick fix is to use something to check if you are in the forum context, like for example if (defined('PUN_ROOT')).

    Don’t hesitate to post if you have any better idea or explication ! It’s more than possible my explications are false as I have a limited understanding of PHP and WordPress. Thanks again.

    Thread Starter C8H10N4O2

    (@c8h10n4o2)

    Additionally, you may need to filter nav_menu_css_class to remove the current-menu-item class from the home link when you’re on the forum index.

    For example, here is the code I’ve used :

    function my_special_nav_class( $classes, $item )
    {
        if( defined('PUN_ROOT') && $item->title == 'Home' )
        {
            $remove_key = array_search( 'current-menu-item', $classes );
    	unset($classes[$remove_key]);
        }
        return $classes;
    }
    add_filter( 'nav_menu_css_class', 'my_special_nav_class', 10, 2 );

    You can add the following snippet before return $classes; to add the curent-menu-item class to the “Forum” link in the navigation. Be sure to use the title of your link if it’s not “Forum”.

    if( defined('PUN_ROOT') && $item->title == 'Forum' )
    {
        $classes[] = 'current-menu-item';
    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Forum index under subdomain considered as home by WordPress’ is closed to new replies.