Skip to:
Content
Pages
Categories
Search
Top
Bottom

Modify Topic Title Tags

  • 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

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

  • chrishajer
    Participant

    @chrishajer

    This is an old post, but the concept still applies:

    https://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).

    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;

    }

    ?>


    chrishajer
    Participant

    @chrishajer

    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;
    }
    ?>

    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)


    chrishajer
    Participant

    @chrishajer

    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.


    sockmoney
    Member

    @sockmoney

    Thanks for this plugin snippet. This is the beauty of this software… so elegant and easy to modify.

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