Skip to:
Content
Pages
Categories
Search
Top
Bottom

Problem with Title Tag in Category and Tag

  • @mikey3d

    Participant

    The problem is the words in the Title Tags for category and tag. Ex:

    1.) How I add category for Hello world!:

    Dashboard > Posts > Categories > Name: New York > Slug: new york > Add New Category

    When I click the category link New York in Hello world!: The page of Title Tag is wrong: Categories » New-york, it suppose to be: Categories » New York.

    Title tag: Categories » New-york
    URL: /blog/category/new-york/

    2.) How I add tag for Hello world!:

    Dashboard > Posts > Edit: Hello world! > Post Tags > Long Island > Add

    When I click the tag link Long Island in Hello world!: The page of Title Tag is wrong: Tags » Long-island, it suppose to be: Tags » Long Island.

    Title tag: Tags » Long-island
    URL: /blog/tag/long-island/

    It will happen only more the one word.

    Thanks, Mikey3D

Viewing 13 replies - 1 through 13 (of 13 total)
  • @mikey3d

    Participant

    Look at the Title Tag for Category New York:
    [Edit/URL]

    Look at the Title Tag for Tag Long Island:
    [Edit/URL]

    @rogercoathup

    Participant

    @mikey3D – there is something wrong in your set up. The default installation/theme shows the title tag with spaces between the words.

    Are you using the default theme unmodified? Have you got any additional plugins running?

    Switch to default theme, disable all plugins and let us know if the title tags now have spaces

    @mikey3d

    Participant

    “There is something wrong in your set up. The default installation/theme shows the title tag with spaces between the words.”

    I have install WordPress and BuddyPress as clean as pure water. Trust me, it is the BuddyPress problem.

    “Are you using the default theme unmodified?”

    Default theme

    “Have you got any additional plugins running?”

    No! Only BuddyPress and I have added bp-custom.php from the last time we talked. I disable bp-custom.php.
    https://buddypress.org/community/groups/requests-feedback/forum/topic/no-title-of-each-posts-and-pages/

    The problem is still the same.

    Thanks, Mikey3D

    @mikey3d

    Participant

    I’m talking about Title Tag, not h3 tag.

    Not h3: You are browsing the archive for New York.

    Title Tag: My blog | Blog | Categories | New-york

    @mikey3d

    Participant

    @rogercoathup,

    Please add category “New York” and tag “Long Island” for “Hello world!” in your post.

    http://playground.21inspired.com/

    Thanks, Mikey3D

    @rogercoathup

    Participant

    @mikey3D

    Yes, sorry – I only checked a multi-word post title.

    You are correct, categories and tag page titles are behaving differently in default BuddyPress vs. default WordPress install

    The function that builds the title in BuddyPress is bp_page_title(). In WordPress it’s wp_title()

    The WP function is doing a lot more work with the category and tag slug, taking the name slug it’s been passed (with the hyphens inserted) and looking up the correct (non-hyphenated) title to insert.

    OK, two things I suggest:

    1. Report this, and suggest that the bp_page_title() function should behave the same as wp_title() for categories, tags, etc. This would be the sensible way for the function to behave IMO. @hnla – is adding this to the trac, the correct way to raise this a possible fix?

    2. For a quick fix, code your own title function, and replace the call to bp_page_title() in your header.php with a call to your own function

    The function may look a little daunting, but should be reasonably straightforward with a bit of judicious copying and pasting from the existing BP and WP functions.

    Cheers, Roger

    @hnla

    Participant

    There is already a Trac ticket on the issue of adding topic titles to bp_page_title() and in general the function is earmarked to be looked into in more depth I will add a link back to this thread so the issue is logged.

    For now I guess you will need to patch as best you can or live with it until 1.3 is released.

    @mikey3d

    Participant

    Thanks, @rogercoathup & @hnla.

    Can I have a patch?

    Thanks, Mikey3D

    @mikey3d

    Participant

    Is there a patch?

    @hnla

    Participant

    @mikey3d did you follow point 2 that Roger explained above? there is no ‘Patch’ as such only what we( the community) can run up given the spare time. tbh this is something I would have not been too concerned with and awaited a core patch in a future release (I have suggested a core patch to address the problem, but that will probably be applied in 1.3 – too late to get in to 1.2.6)

    If you want you can try this quick fix I’ve run up by exacting the relevant section from the core function and applying it as a filter in functions.php – it’s not widely tested and slightly hackish but appears to work:

    `function bp_page_title_blog_category_remove_hyphens( $title ) {
    global $bp, $wp_query;
    if ( defined( ‘BP_ENABLE_MULTIBLOG’ ) ) {
    $blog_title = get_blog_option( $current_blog->blog_id, ‘blogname’ );
    } else {
    $blog_title = get_blog_option( BP_ROOT_BLOG, ‘blogname’ );
    }
    if ( bp_is_blog_page() && is_category() )
    $title = __( $blog_title . ‘| Blog | Categories | ‘ . ucwords( $wp_query->query_vars ), ‘buddypress’ );
    $title = str_replace(‘-‘, ‘ ‘, $title);
    return $title;
    }
    add_filter( ‘bp_page_title’, ‘bp_page_title_blog_category_remove_hyphens’ );
    `

    Let us know if that works for you?

    @mikey3d

    Participant

    It almost did works but…

    There are two conflict codes for my title (/plugins/bp-custom.php) and your remove hyphens (/themes/my theme/function.php). The problem is your codes it only remove hyphen and it does not remove the first lowercase letter of second word. Ex:

    The words New York:

    1.) My title of category is “Category » New-york | My blog”

    2.) Your remove hyphen title of category is “My blog| Blog | Categories | New york”

    Can these codes put together in bp-custom.php if it could have two words with space, capital letter and my ways of doing the titles?

    Thanks for your help, Mikey3D

    @hnla

    Participant

    here’s a quick adaptation then to give you all words uppercase, as for the order things are written in if you look at the first instance of $title you will see how the various parts are constructed, it’s a string so follows the order you read in, have a play around to get the order of things the way you want. if you want specific characters then you need to look up ‘html character entity codes’ to get things like ‘ » ‘

    `function bp_page_title_blog_category_remove_hyphens( $title ) {
    global $bp, $wp_query;
    if ( defined( ‘BP_ENABLE_MULTIBLOG’ ) ) {
    $blog_title = get_blog_option( $current_blog->blog_id, ‘blogname’ );
    } else {
    $blog_title = get_blog_option( BP_ROOT_BLOG, ‘blogname’ );
    }
    if ( bp_is_blog_page() && is_category() )
    $title = __( $blog_title . ‘| Blog | Categories | ‘ . $wp_query->query_vars , ‘buddypress’ );
    $title = str_replace(‘-‘, ‘ ‘, $title);
    $title = ucwords($title);
    return $title;
    }
    add_filter( ‘bp_page_title’, ‘bp_page_title_blog_category_remove_hyphens’ );`

    @mikey3d

    Participant

    @hnla, It works! :-)

    Thanks, Mikey3D

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Problem with Title Tag in Category and Tag’ is closed to new replies.
Skip to toolbar