Team Name & Permalink in Post Title
-
I’m trying to get the Current Team name in the post title, under Player Details — as a kind of breadcrumb.
By tweaking sp-template-hooks.php, I’ve been able to do something. But its not perfect. I suspect I’m looking in the wrong place/barking up the wrong tree.
Any advice?
function sportspress_the_title( $title, $id = null ) {
if ( ! $id ) {
return $title;
}
if ( ! is_admin() && in_the_loop() && $id == get_the_ID() ) :
if ( is_singular( 'sp_player' ) ) :
$number = get_post_meta( $id, 'sp_number', true );
$current_team = get_post_meta( $id, 'sp_team', true );
$url = get_post_meta( $id, 'sp_url', true );
if ( $number != null ) :
$title = '<strong class="sp-player-number">' . $number . '</strong> ' . $title . ' | ' . '<a href="' . $url . '">' . $current_team . '</a>';
endif;
elseif ( is_singular( 'sp_staff' ) ) :
$staff = new SP_Staff( $id );
$role = $staff->role();
if ( $role ) {
$title = '<strong class="sp-staff-role">' . $role->name . '</strong> ' . $title;
}
endif;
endif;
return $title;
}
add_filter( 'the_title', 'sportspress_the_title', 10, 2 );The page I need help with: [log in to see the link]
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Team Name & Permalink in Post Title’ is closed to new replies.