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! 🎄
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' );
To clarify, I'm looking for the PHP variable of "wpforo-title"
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' );
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
@robert just circling back here to let you know that this function works beautifully. Thanks very much