bbPress

Simple, Fast, Elegant

bbPress support forums » Themes

Modify Topic Title Tags

(6 posts)
  • Started 5 months ago by photolord
  • Latest reply from chrishajer
  • This topic is resolved
  1. I looked on here, but wasn't quite able to find how to do this. If I missed it I apologize. How would I modify topic titles to not have the name of the forum in the title? What would I change? What file would I modify? Such as:

    This is the default title structure right now on my theme:
    <title>Topic Title >> Forum Name</title>

    I would like to change the title structure to this:
    <title>Topic Title</title>

    Any ideas? Thanks.

    Best regards,

    Matt

    Posted 5 months ago #
  2. This is an old post, but the concept still applies:
    http://bbpress.org/forums/topic/title-tags#post-9045

    bb_title is the function you need to override with a plugin, such as this one. To see what bb_title and bb_get_title do, take a look at bb-includes/template-functions.php starting around line 305 (in version 0.9.0.2).

    Posted 5 months ago #
  3. Do you know what I did wrong? When I try to activate the plugin I get:

    Plugin could not be activated; it produced a Fatal Error.

    I want to get rid of the site title that comes after the topic title on topic pages. That way I'll only have the <title>Topic Title</title> in the browser. I need some expert coder help. :o) This is what I have that did not work:

    <?php
    /*
    Plugin Name: Title Modifier
    Author: Matt George
    */
    add_filter('bb_title', 'titlemodify');

    function titlemodify( $title ) {
    //your code that does something to $title;

    case 'topic-page':
    $title[] = get_topic_title();

    return $title;
    }
    ?>

    Posted 5 months ago #
  4. I don't think you can do a case without a switch first. Something like this:

    <?php
    /*
    Plugin Name: Title Modifier
    Author: Matt George
    */
    add_filter('bb_title', 'titlemodify');
    
    function titlemodify( $title ) {
    //your code that does something to $title;
    
    switch ( bb_get_location() ) {
            case 'topic-page':
                    $title[] = get_topic_title();
                    break;
    }
    return $title;
    }
    ?>
    Posted 5 months ago #
  5. It gave me this error:

    Fatal error: [] operator not supported for strings in /home/prayer81/public_html/my-plugins/titlemodifier.php on line 13

    So I took out [] and it works like a charm. Sweetness! Big thanks! I guess this is like my first attempt at a plugin. ;o)

    Posted 5 months ago #
  6. I think that is a case of mixing an array ($title[]) with a string ($title). Somewhere, $title is being used as a string, and this piece of code wants to use it as the array $title[].

    Glad you got it working. Hack away.

    Posted 5 months ago #

RSS feed for this topic

Reply

You must log in to post.

Code is Poetry.