Forums

Join
bbPress Support ForumsPluginsForum title in bb_title on topic page

Info

Forum title in bb_title on topic page

  1. It was annoying me that by default bb_title() on the topic page didn't include the name of the forum in it. I wanted

    Topic name < Forum name < Site name

    but bb_title() default is:

    Topic name < Site name

    So I wrote this little plug-in and now I'm happier.

    <?php
    /*
    Plugin Name: Better Topic Titles
    Plugin URI:
    Description: Add the forum (category) name to the topic title in <title> for the love of SEO!
    Author: Phil Thompson
    Version: 1.0
    Author URI: http://imgiseverything.co.uk/
    */

    function better_topic_titles($title){

    $separator = '«';

    $forum_name = get_forum_name();

    if(!empty($forum_name) && strpos($_SERVER['REQUEST_URI'], 'topic') !== false){
    $title = str_replace($separator, $separator . ' ' . $forum_name . ' ' . $separator, $title);
    }

    return $title;
    }

    add_filter('bb_title', 'better_topic_titles');

    ?>

    I've not found any issues with using it but I'm sure someone can have a look and improve it; if they think it's necessary.

  2. I suggest you add this plugin to the bbPress plugin repository. Seems like it would be useful to some. Thank you.

    http://bbpress.org/plugins/requests/

  3. You must log in to post.