Making WordPress SEO plugin compatible with BuddyPress

Are you using the WordPress SEO plugin by Joost de Valk. I have recently started using it on BuddyDev and noticed that for BuddyPress pages, It was not generating the title and meta properly. For example, when I visited my own profile, the title said "Members | BuddyDev" while  I wanted it to be like "Brajesh | Members | BuddyDev" or something on the line that makes it more specific.

Also, I don't want to change my theme code and be completely dependent on WordPress SEO plugin, who knows the future, we may switch to something else. So, I wrote a couple of lines to fix the title/meta for BuddyPress User/Group pages when using WordPress Seo plugin.

You can put these codes in your bp-custom.php(or theme's functions.php) and It will work.

Fixing Title for BuddyPress Components:-

To fix the title, all I had to do was to stop WordPress Seo plugin from generating titles for BuddyPress generated pages and let BuddyPress do it. Here is the code to do that.

In the above code, I am checking if the current page is generated by BuddyPress and if that is true, I am simply avoiding title generation by the WordPress Seo plugin. BuddyPress already filters on wp_title and generates the appropriate title for me.

So, we are done with the title, and It all looks good.
Do you want to modify the meta description too? By default, WordPress SEO plugin will take the description from the directory page( If you have set the meta description the in the page edit screen or set a template for it ). This description is not appropriate as It is not generated to be specific for individual single item( User/group etc).

Here is a code that you can use to overcome that. I am putting a basic version and hope that you can adapt it using your own SEO skills.

Dynamically generating meta description for individual components:-

Well guys, what do you think? Do we need to change other aspects too. Please do share your thoughts in the comments below.

31 Responses to Making WordPress SEO plugin compatible with BuddyPress

  • Hello Brajesh! You know how many people have been looking for a fix for BuddyPress and WordPress SEO? 😛 LOTS.

    I put the suggested code in my bp-custom.php but for some reason it doesnt seem to be changing the Members SEO titles. They are still WordPress SEO's titles. Any suggestions? Thanks!

    • Hi Kyle,
      I am extremely sorry for ignoring your comment. You have been a valuable member here and I am sorry I missed you post while I was struck in my other problems.

      My I offer you some help now? Are you still willing to use this code? Please do let me know .


      • Thanks Brajesh, but I think I finally got it to work.

    • Thank you Martin.
      Those will certainly help with some canonical issue(I believe BuddyPress already does that now). Will look further into that 🙂

      • Well, I think a whole pile of folks would love you code expanded upon with some of your research so WPSEO and BuddyPress can really work seamlessly and better than what it does now.
        Any further code enhancements will certainly be appreciated.

        • Thank you Martin. I am certainly looking forward to do more experiments as I am using the WPSEO plugin on BuddyDev too 🙂 Hope to put some more time this weekend.

        • You get any further on this Brajesh?
          Sorry, clicked the wrong reply button further down 🙂

  • Brajesh,

    Your code snippet is different than the one from bp-tricks.

    Do you know what the one from bp-tricks actually does? Then, I can get a better idea which one to use.

  • Just saw the error on one of my website, was wondering what might be the issue. Lucky for me, i saw this link in someone else's tweet. Just copied the code, and of course it works.. Thank you

  • Thanks for this Brajesh. Both code snippets work well on my site.

    I'm using the latest BP and WPSEO, with the latest bbPress forums inside BP Groups. I would like to enhance your meta title and meta description snippets to work properly for these bbP forum/topic pages too. I think it should be fairly simple but I can't figure it out. I think quite a few others are also wanting this so I was wondering if you would please give us some guidance on how to enhance your code to do this.

    Currently, for each bbPress forum/topic I can enter the meta title and meta description via the standard WPSEO entry fields, and WPSEO generates the meta title and meta description only if the bbPress forum/topic page is NOT inside a BP Group.

    But when I associate the same bbPress forum/topic with a BP group (i.e. so that forum/topic displays under a tab in the BP group), then the WPSEO meta title and meta description are not generated for the page. How do I fix this?

    Thanks in advance.

    • Hi Marc,
      I am sorry I could not check your post earlier.
      have you found a solution to this issue or need some solution. It will be fun to add support for group forums. If you are still looking for it, please do let me know 🙂

      • Glad to hear back from you Brajesh – I had been wondering what happened to my post.

        Yes, I am still looking for a solution to get this working with latest bbPress forums inside BP Groups. In fact, I am also looking for a similar solution for the BuddyPress Groups Extras plugin pages inside BP Groups.

        • Sorry for the inconvenience Marc. I am including this for this week's schedule. will get back to you by weekend 🙂

        • Many thanks Brajesh – I look forward to this and will be happy to help out by testing on my site asap and reporting back here.

          I really need to get this working for Buddypress Groups pages that contain bbP forums & topics and also BuddyPress Groups Extras pages. WPSEO already provides the UI to enter distinct titles and meta descriptions for all these pages. Just need to work out a way to get them onto the page 🙂

          I think this is a really valuable thing to achieve for SEO for Buddypress plugins, as Google Webmaster Tools continues to indicate high importance for relevant and distinct titles and metadescriptions for all pages on a site. See https://support.google.com/webmasters/answer/35624?hl=en&ref_topic=2371375

        • Hi Brajesh,

          Just wondering where you are at on this one? It will be a real leap forward for BuddyPress SEO if you can manage to do it.

  • About the second code – what to add, if I am using your BuddyBlog plugin (together with custom post type)?

    • Hi Justina,
      That will be some custom code but I like your suggestion about BuddyBlog integration. I will post some snippet in a day or 2 with details.
      My apologies for the delayed reply.

  • Hey, I tried this (both in functions.php and bp-custom.php), but nothing happened.

    • Hi Nykess,
      I am sorry for the delayed reply.
      Are you still stuck with this issue?

  • I'm using the code as well. After a long search and complains to Joost for not making his popular SEO plugin compatible with the even more popular BP plugin, I found this solution, which is by the way the only one that works!!! Thanks

    • Hi Giorgos,
      Thank you for the comment and confirming. appreciate you taking time to comment 🙂

  • Too complex, it will be ok I can add title keywords and description.

    • Hi Tim,
      I am sorry if it looked complex to you. Will try to improve in future if I can.

      In case you need any help with the code, please do let me know. My apologies for delayed reply. Been too busy recently.

    • I second Martin's suggestion for further code enhancements. Lets say members subpages is just titled "membersname" profile., instead of "membersname gallery" when on gallery pages, or "membersname forum replies" when on forum replies pages.

  • I second Martin’s suggestion for further code enhancements. Lets say members subpages is just titled “membersname” profile., instead of “membersname gallery” when on gallery pages, or “membersname forum replies” when on forum replies pages.

  • Here is the update that fixes all the issues as we discussed above