Hi Sebastian
This is possible only with custom coding. We don’t have an option for that at the moment, unfortunately.
Thanks!
Thread Starter
sg88
(@sg88)
Hi @rochesterj,
yeah, I assumed that.
Since I am pretty new to WordPress, do you have a hint for me how I can implement that? π
Best regards,
Sebastian
Hi Sebastian!
Thanks for your reply, it’s always good to see you.
It’s hard to know which page you are editing from your screenshot (if possible, please always post non-cropped screenshots, as we have the same element in multiple pages).
It’s probably easier to edit the SP functions that load that item, but maybe you can use a general filter like this one:
https://developer.ww.wp.xz.cn/reference/hooks/the_title/
Let me create a simple snippet so you can try it out.
-
This reply was modified 4 years, 7 months ago by
Roch. Reason: accidentally hit send
Hi Sebastian
So, something like this is going to change all titles for all teams in the entire wp-admin. Then you need a bit of code here and there to correctly filter it only in the places you want to:
add_filter('the_title', 'sp_custom_sp_team_title', 10, 2);
function sp_custom_sp_team_title( $title, $id ) {
if ( is_admin() && 'sp_team' == get_post_type( $id ) ) {
$leagues = get_the_terms($id, 'sp_league');
if ( ! empty($leagues ) ) {
$title = $title." - ";
foreach ( $leagues as $league ) {
$title = $title.$league->name . ", ";
}
}
}
return $title;
}
Thanks!
Thread Starter
sg88
(@sg88)
Hi @rochesterj,
Thank you very very much for that snippet, it really helps me a lot to understand WordPress bit better π
I have tried you snippet within my child theme, and it is working great on the team overview in the admin theme. However, it is not working while selecting a team in the add/update player page:
https://prnt.sc/1y9a283
Do you’ve got another hint how I got solve that? π
Best regards,
Sebastian
-
This reply was modified 4 years, 7 months ago by
sg88.
Thread Starter
sg88
(@sg88)
In the meantime I’ve got a step further and figured out where this data is coming from.
The selection is based on sp-core-functions.php -> sp_dropdown_pages.
Line 923
printf( '<option value="%s" class="%s" %s>%s</option>', $this_value, $class, $selected_prop, $post->post_title . ( $args['show_dates'] ? ' (' . $post->post_date . ')' : '' ) );
The next thing I will try to do it to overwrite this function within my child theme while trying not to break anything else.
By the way, do you accept pull requests for Sportspress? I started thinking about providing a setting for the Plugin to make this a bit more elegant.
Thread Starter
sg88
(@sg88)
Ok that’s a thought one.
Since the Sportspress base class is defined as final (sportspress.php), I ain’t got a chance to overwrite the function sp_dropdown_pages without hacking the module, which I really don’t want.
The next thing I will try to do is to provide a patch for the plugin that will make this configurable and hope that the Pull request gets accepted π
Could you please provide me a little guideline how I can contribute to this Plugin?
-
This reply was modified 4 years, 7 months ago by
sg88.
Hi Sebastian!
Thanks for your reply.
I can see that you’ve made a fork for this change. Thanks for doing that!
I can’t guarantee that it will make it into the main release, but at least you have the code to do it already.
Thanks!