• Resolved bati1975

    (@bati1975)


    Hi, I would like to customize my club template and for this, I wanted to know if there is documentation on the variables to use to take the elements that make up the clubs, players, coach, etc.
    Thank you.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Contributor Savvas

    (@savvasha)

    Hi there @bati1975 ,

    You can use SportsPress shortcodes for this.

    Thanks,
    Savvas

    Thread Starter bati1975

    (@bati1975)

    Hello Savvas again. I understand that I can use shortcodes. But for example, in the player gallery I would like the position to appear below the name (as I show you in the image or similar) for both players and staff.

    I can’t find a way and that’s why I thought about creating my own template. On the other hand, I would like it not to initially have a link to the player’s page.
    You could make code from functions.php perhaps if the plugin doesn’t support this.
    If you can tell me where I can find the file I need to modify, I will appreciate it (if I didn’t have this option originally).
    Thanks Savvas!

    Plugin Contributor Savvas

    (@savvasha)

    To achieve exactly what you want you will need to copy default templates from wp-content/plugins/sportspress/templates/ to wp-content/themes/your-child-theme/sportspress and alter them exactly as you want.

    For example, for the case above with player gallery, you should copy player-gallery-thumbnail.php template file and make an alteration to line 33:

    $caption = '<' . $captiontag . ' class="wp-caption-text gallery-caption small-3 columns' . ( '' !== $player_number ? ' has-number' : '' ) . '">' . wptexturize( $caption ) . '</' . $captiontag . '>';

    so as to include the info you want.

    Thanks,
    Savvas

    Thread Starter bati1975

    (@bati1975)

    Thanks Savvas, it’s been very helpful. Here’s a sample of how it turned out after modifying the code a bit.

    On the other hand, I can’t find where to modify the date of birth. I’d like to show only the year (for legal reasons here in my country the whole date can’t be shown) but I can’t find the line of code that refers to that in the player’s file.

    I don’t want to abuse your good will, but are you clear on this? Do you know where it is?

    Plugin Contributor Savvas

    (@savvasha)

    You can show the Age instead at SportsPress->Settings->Players

    Thanks,
    Savvas

    Thread Starter bati1975

    (@bati1975)

    Yes, I know. But if I want to see only the year, not the full date: Ex: 2009 (not 27-08-2009) What is the variable or where do I find that instruction?

    Plugin Contributor Savvas

    (@savvasha)

    Try to add the following code to your child theme functions.php :

    function bati1975_modify_birthday_to_year( $data, $id ) {
    // Check if 'Birthday' key exists in the array.
    if ( isset( $data[ esc_attr__( 'Birthday', 'sportspress' ) ] ) ) {
    // Extract the birthday
    $birthday = $data[ esc_attr__( 'Birthday', 'sportspress' ) ];

    // Create a DateTime object from the string.
    $date = DateTime::createFromFormat('d/m/Y', $birthday);

    // Check if the date was created successfully.
    if ( $date ) {
    // Format the date to just get the year.
    $year = $date->format('Y');

    // Update the Birthday field with just the year.
    $data[ esc_attr__( 'Birthday', 'sportspress' ) ] = $year;
    } else {
    $data[ esc_attr__( 'Birthday', 'sportspress' ) ] = 'Invalid date format';
    }
    }

    return $data;
    }

    // Add the filter to modify the player details.
    add_filter('sportspress_player_details', 'bati1975_modify_birthday_to_year', 30, 2);

    Thanks,
    Savvas

    Thread Starter bati1975

    (@bati1975)

    It worked! You deserve a mention… if you want a backlink to your site or a project, let me know and I’ll be happy to give it to you.

    Plugin Contributor Savvas

    (@savvasha)

    Hi there @bati1975 ,

    I am glad you sorted it out ?? If you want please add a positive review at https://www.ads-software.com/support/plugin/sportspress/reviews/

    Thanks,
    Savvas

    Thread Starter bati1975

    (@bati1975)

    Done!

    Plugin Contributor Savvas

    (@savvasha)

    Thanks!

Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.