BP_RankMath_Title filter and hook

#52277
  • Resolved Anonymous
    Rank Math free

    Hi there,

    I realized that the BP_RankMath_Title has this line of codes:

    if ( bp_is_user() ) {
    $title = get_user_meta( bp_displayed_user_id(), ‘first_name’, true );

    Basically I do not want bp_is_user to show first name nor last name, I just want it to show %title% %sep% %sitename%.

    Do you mind guide me how I can create a hook in function.php to override that code?
    In filters-hooks-api-developer document I found “Filter to change the Title.” but I have no idea how to utilize it for this case.

    Looking forward to hear from you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Alberto
    Rank Math business

    Hello,

    Thank you for contacting Rank Math today.

    You could implement the filter and check if the current page is a user page and if it is, modify the title as you wish. I have made a little template so you can do it easily:

    /**
     * Filter to change the page title.
     * 
     * @param string $title
     */
    add_filter( 'rank_math/frontend/title', function( $title ) {
            if ( bp_is_user() ) {
               // Modify the $title var as you wish
               $title = ....;
            }
    	return $title;
    });

    Looking forward to helping you. Thank you.

    ​​​​​​

    Anonymous
    Rank Math free

    Hi,
    Where do I implement this code? I tried it in function.php, it’s not reflecting in bp user profile title.

    Anonymous
    Rank Math free

    it’s alright I have figured out. Thanks!

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

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

The ticket ‘BP_RankMath_Title filter and hook’ is closed to new replies.