Notifications
Clear all

Script [Solved] How to remove the forum title from the html tag

6 Posts
3 Users
0 Reactions
431 Views
Posts: 10
 ziv7
Topic starter
(@ziv7)
Eminent Member
Joined: 7 months ago

I would like to have my html title tags like this:
Topic title - Site title
In other words, i would like to EXCLUDE the forum name title. How do I do that?

5 Replies
Sofy
Posts: 4909
 Sofy
Admin
(@sofy)
Support Team
Joined: 7 years ago

Hi,

Please read this documentation: https://wpforo.com/docs/wpforo-v2/settings/display-components/#show-forum-page-title

Robert
Posts: 10591
Admin
(@robert)
Support Team
Joined: 9 years ago

Hi @ziv7,

I assume you're talking about Meta Title. If so you should use the title hook to remove whatever you want. The hook code looks like this, it should be added in Code Snippets plugin or directly in the current active theme's functions.php file:

add_filter('wpforo_seo_topic_title', function ($title){
if( function_exists('WPF') ){
$forum_title = WPF()->current_object['forum']['title'];
return str_replace($forum_title, '', $title);
}
return $title;
} );
3 Replies
 ziv7
(@ziv7)
Joined: 7 months ago

Eminent Member
Posts: 10

Posted by: @robert

Hi @ziv7,

I assume you're talking about Meta Title. If so you should use the title hook to remove whatever you want. The hook code looks like this, it should be added in Code Snippets plugin or directly in the current active theme's functions.php file:

add_filter('wpforo_seo_topic_title', function ($title){
if( function_exists('WPF') ){
$forum_title = WPF()->current_object['forum']['title'];
return str_replace($forum_title, '', $title);
}
return $title;
} );

 

Hey Robert!
Amazing! that's exactly what I needed.  Thank you so much!!!!!

One more little thing, if possible: now, after adding your code to my child theme, the meta titles tags of each particular topic (thread) look like this: 
Topic title - mysite.com Forum

Is it possible (by customizing your code or another way) to apply these 2 minor changes?
1. To remove the word "Forum" from the title
2. To capitalize the first character of the site's domain name?

If done correctly, the meta title tags will look like this: 

Topic title - Mysite.com

 

 

Sofy
 Sofy
Admin
(@sofy)
Joined: 7 years ago

Support Team
Posts: 4909

@ziv7

Please navigate to the Dashboard > wpForo > Boards admin page. Find the current board, edit it, and change the board title as you like.

 ziv7
(@ziv7)
Joined: 7 months ago

Eminent Member
Posts: 10

Posted by: @sofy

@ziv7

Please navigate to the Dashboard > wpForo > Boards admin page. Find the current board, edit it, and change the board title as you like.

 

Very helpful - thanks!