Notifications
Clear all

Limited Support

Our support team is currently on holiday from December 25, 2025 to January 7, 2026, and replies may be delayed during this period.

We appreciate your patience and understanding while our team is away. Thank you for being part of the wpForo community!

Merry Christmas and Happy Holidays! 🎄

[Closed] Get forum / topic title

5 Posts
2 Users
3 Reactions
3,632 Views
Posts: 392
Topic starter
(@anonymous3542)
Honorable Member
Joined: 8 years ago

Hi @robert,

Is there a function that displays the forum or topic title ? I have a header on my community page that I would like to change to be the forum or post title dependant on the selection.

I thought I could use something like this, but it doesn't seem to work

function vComp4(){
$getwpforotitle = $post['title'];
if(empty($getwpforotitle))
{
$getwpforotitle = "Title is empty";
}
return $getwpforotitle;
}
add_shortcode( 'wpforo-get-title', 'vComp4' );

4 Replies
Posts: 392
Topic starter
(@anonymous3542)
Honorable Member
Joined: 8 years ago

To clarify, I'm looking for the PHP variable of "wpforo-title"


Robert
Posts: 10595
Admin
(@robert)
Support Team
Joined: 10 years ago

I'm sorry but there is no an easy way do do this. I'd recommend this code, it may work.

function vComp4(){
if( is_wpforo_page() ){
if( wpfval(WPF()->current_object, 'topic', 'title') ) {
$title = WPF()->current_object['topic']['title'];
} elseif( wpfval(WPF()->current_object, 'forum', 'title') ) {
$title = WPF()->current_object['forum']['title'];
} elseif( wpfval(WPF()->current_object, 'user', 'display_name') ) {
$title = WPF()->current_object['user']['display_name'];
} else {
$title = "Title is empty";
}
}
return $title;
}
add_shortcode( 'wpforo-get-title', 'vComp4' );

Posts: 392
Topic starter
(@anonymous3542)
Honorable Member
Joined: 8 years ago

Thanks @robert. I'll give this a try. If all else fails, there's always wp_title() and regex. A little clunky, but would do the job I expect - just not very efficiently


Posts: 392
Topic starter
(@anonymous3542)
Honorable Member
Joined: 8 years ago

@robert just circling back here to let you know that this function works beautifully. Thanks very much