• Resolved Arnan de Gans

    (@adegans)


    Today I noticed that with The SEO Framework (TSF) on bbPress profile titles are not shown correctly.
    If I disable TSF the titles are empty, but that’s fixed with this code.

    /* ----------------------------------------------------------------
    // Fix broken BBPress titles
    ---------------------------------------------------------------- */
    function ajdg_bbp_title($parts) {
        if (empty($parts['title']) && is_bbpress()) {
            $parts['title'] = trim(bbp_title('', ''));
        }
        return $parts;
    }
    add_filter('document_title_parts', 'ajdg_bbp_title');

    Yes, bbPress is not free of fault as well in this. But the proposed fix/workaround doesn’t work as long as The SEO Framework is enabled.

    I found some similar issues with other plugins and TSF, and all were dismissed as the other plugin having issues. But I lean to an issue in TSF as this is yet another plugin that has this (or a very similar) issue in combination with TSF.

    Regardless of where it breaks. I need/want this to work and the only logical solution I can find is that TSF either ignores bbPress profile page titles, or stops overwriting them. Since Topic and Reply titles work fine with TSF, well… TSF is missing something I think.

    For example what can change is that TSF checks if the title is empty. If not, use the original string (instead of setting it to ‘untitled’) if TSF doesn’t know what to do with it. Simple enough.

    Please advise!

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hello!

    We shortcircuit the wp_get_document_title() function via pre_get_document_title, so document_title_parts will never run.

    Now, since bbPress doesn’t provide a proper user object on the profile page, we can’t do much with that in regards to detecting the query; so, the fallback “untitled” title is used.

    Unfortunately, we don’t have a system in place which can use other titles that might’ve been provided. We solely rely on the WordPress API for that, at a level higher than the short-circuit. I’m not sure if jerry-rigging another fallback is beneficial, but that would reduce the likelihood of these things failing.

    In any case, you’re the first that tells us about this issue, thank you for that! I’m going to see if I can add a compatibility layer to TSF for bbPress so that we can detect the said user pages and provide proper metadata handling for it. The next minor update is planned for this Tuesday, I’ll try to add it to that update.

    If you find any more issues, let me know. Cheers!

    Plugin Author Sybre Waaijer

    (@cybr)

    Thread Starter Arnan de Gans

    (@adegans)

    Maybe I’m the first for the bbPress / SEO Framework combination but similar issues exist for other plugins.

    And skipping filters/hooks to get TSF stuff working seems like a flaw.

    Looking forward to your fix 🙂 Thanks for the quick reply.

    Hey all! bbPress lead chiming in. I for one am very open to patching anything that makes tweaking SEO in bbPress easier.

    bbPress 2.x still has support for both page title approaches in WordPress itself, the old and the new. The new is a few years old, but was not finalized (and was still buggy) when bbPress needed to ship with support for it. I wouldn’t be surprised if it’s less than ideal today.

    @cybr if you’re willing to write out what’s missing in bbPress, I’ll do my best to make sure bbPress gets the improvements you need. 👍

    Thread Starter Arnan de Gans

    (@adegans)

    @johnjamesjacoby Hi John, as you can read in my initial post, the titles for profiles and such in bbPress don’t work at all for some reason. Topics and replies work fine.
    I’ve tested this on a bare WP with no other plugins but using Storefront and on my live site.

    I need to add the snippet ^ to get titles to work. This is a bit of a shortcoming or bug in bbPress currently I think.

    Plugin Author Sybre Waaijer

    (@cybr)

    The topics and replies work fine because there’s a WordPress Post Object post_title property present. But, bbPress’s template would like to show Topic: %s–which currently isn’t the case when TSF is active.

    ——

    Thanks for chiming in JJJ (@johnjamesjacoby)! Here are my thoughts:

    Titles
    What I would like to see is a simple function that processes the title for the current request. Something like: bbp_get_title().

    In essence, bbp_get_title() should do everything bbp_title() does, without the processing/appending of the separator and blog name. Here’s the code I’m envisioning for that function.

    Therein, filter bbp_raw_title should be replaced, because we don’t work with providing title parts anymore (thanks to the infamous wp_title filter…). I’d like to suggest a new filter that can adjust the output, identical to the function name: bbp_get_title.

    In extent, you could create bbp_filter_document_title_parts(), which filters document_title_parts, providing that title. E.g.:

    add_filter( 'document_title_parts', 'bbp_filter_document_title_parts' );
    function bbp_filter_document_title_parts( $title ) {
    
    	if ( is_bbpress() ) {
    		// You may want to use strlen instead of ?:
    		$title['title'] = bbp_get_title() ?: $title['title'];
    	}
    	
    	return $title;
    }

    Keep in mind that you still should support wp_title; so, removing/changing bbp_title() as it currently functions wouldn’t be wise.

    Canonical URLs
    We also have an issue with the canonical URL. WordPress has, since v4.6, a function called wp_get_canonical_url(). In that function, there’s a canonical URL you can provide. It’d be great if you could supply the correct canonical URL to that filter 🙂

    Other SEO functionality
    Now, in WordPress, there’s no default way to provide Open Graph, a meta description, or other metadata besides the title tag and canonical URL. So, I’m not sure if you can make it more compatible with SEO plugins–other than the aforementioned augmentation of the canonical URL filter and providing us an integral API function for the title.

    Query compatibility
    As for not detecting a user-query via the WordPress API… well, that requires some arcane rewrite magic, which I don’t believe you should engage with further. I think it’s best to keep that as-is and let other developers use custom functionality, like bp_is_user(), when we desire to expand support.

    I hope these insights are helpful 🙂 Cheers!

    • This reply was modified 3 years, 12 months ago by Sybre Waaijer. Reason: markup
    Thread Starter Arnan de Gans

    (@adegans)

    4.0.7 now shows correct titles 🙂
    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘bbPress titles ‘untitled’’ is closed to new replies.