Skip to:
Content
Pages
Categories
Search
Top
Bottom

Making Forum Tab hilited when viewing forum

  • I am using the StudioPress theme and I have fully integrated bbpress into the theme. I think it looks great, and all the pages seem to be working. View at http:.//mipages.net/forum/ The only problem is that the “forum” tab isn’t hilited when viewing the forum. It always does the “home” one instead.

    In my theme I hardcoded the first forum link to http://mipages.net/forum/

    The second forum link is actually to just a page I created in wordpress called “forum”. I thought I could edit the link in phpmyadmin to http://mipages.net/forum/ somehow but I couldn’t seem to figure it out. So the link for the second forum tab is actually just a page, and not the actual forum.

    So basically I just want one of those forum tabs to be hilited when viewing the forums. It doesn’t matter to me how to get it done. Any suggestions by anyone?

    below is my header code for the forum page.

    Code:
    <div id=”nav”>
    <?php function get_the_pa_ges() {
    global $wpdb;
    if ( ! $these_pages = wp_cache_get(‘these_pages’, ‘pages’) ) {
    $these_pages = $wpdb->get_results(‘select ID, post_title from ‘. $wpdb->posts .’ where post_status = “publish” and post_type = “page” order by ID’);

    }
    return $these_pages;
    }

    function list_all_pages(){

    $all_pages = get_the_pa_ges ();
    foreach ($all_pages as $thats_all){
    $the_page_id = $thats_all->ID;

    if (is_page($the_page_id)) {
    $addclass = ‘ class=”current_page”‘;
    } else {
    $addclass = ”;
    }
    $output .= ‘<li’ . $addclass . ‘>ID).'” title=”‘.$thats_all->post_title.'”><span>’.$thats_all->post_title.'</span>‘;
    }

    return $output;
    }
    ?>

      <?php

      if (is_home()) {
      $addclass = ‘ class=”current_page”‘;
      } else {
      $addclass = ”;
      }
      echo “<li” . $addclass . “><span>Home</span>“;

      if (is_page(‘190’) ) {
      $addclass = ‘ class=”current_page”‘;
      } else {
      $addclass = ”;
      }
      echo “<li” . $addclass . “><span>Forum</span>“;

      echo list_all_pages();?>

    <div class=”cleared”></div>
    </div> <!– Closes Nav –>

    I changed the code to use the function is_page() when trying to identify it as a forum because that is what it looked like I needed to use, but I’m still pretty new to wordpress functions. the “190” is the id of the entry in my wp_posts table that contains the guid of http://mipages.net/forum/ (the link itself)

    So I know it is kind of working, because it is grabbing the right url and everything, I just can’t get it to recognize that is is viewing that current page to add the class.

    Help anyone! As soon as I can get this resolved I’d like to publish the modified theme files so other users can easily implement bbpress with their studiopress theme.

Viewing 8 replies - 1 through 8 (of 8 total)

  • chrishajer
    Participant

    @chrishajer

    That is way too complicated for what you want to do. Hurts my head just to look at it.


    chrishajer
    Participant

    @chrishajer

    Remove the second forum link/page.

    Hardcoding the first forum link in your WordPress header.php is fine. Without any styling, that means it will just be a link to your forum page, and inside WordPress, it would NEVER need to be styled as current, because you’ll never be in WordPress when you are in your forum, right?

    How are you getting the WordPress navigation in the forum? That’s where we need to focus on getting the current class on the forum page tab. If you’re including the WordPress navigation by integrating WordPress inside bbPress, then there needs to be a little work done on getting the current class on the forum tab (since you won’t actually ever be on a page called forum for is_page('forum') or is_page('190') to work properly from WordPress.

    Having this same issue. Have integrated BBpress into WP, or the other way around depending on your definition I guess.

    One of the near final remaining issues is this current_page issue. The forum front page correctly shows the current page in the nav menu (forum is item 5 in the nav menu), but any forum links beyond the forum front page, the 2nd page in the nav menu becomes active (# 2 in the nav menu is the site blog).

    I guess I need to update something somewhere, but really am at a loss as to what & where.

    If you can read this, and can help, please follow up as it seems there is no info on the topic otherwise!


    chrishajer
    Participant

    @chrishajer

    Can you post a screenshot of what’s working and what’s not?

    thindery is no longer using bbpress.

    Casemon, it depends how you integrated the theme. Are you using BBpress’ header.php or WordPress’ header.php?


    Gautam
    Member

    @gautam2011

    Make it:

    if (strtolower($thats_all->post_title) == "forum" || strtolower($thats_all->post_title) == "forums") {
    $addclass = ' class="current_page"';
    } else {
    $addclass = '';
    }

    Am using the WP header.

    As for screenshot, do you really want to see a pic of some bold text saying “blog”? Not sure that would help. The issue is that on any forum page, the WP nav menu highlights the blog menu item instead of the forum menu item. If still yes, let me know and I’ll gladly oblige.

    Gautam; how does your solution work for other sites?

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
Skip to toolbar