• Resolved zacksack

    (@zacksack)


    The current available formats for games are: competitive, friendly and tournament; I want to add 4 custom formats.

    I went through the plugin’s source code and I noticed that ‘Competitive’ and ‘Friendly’ are parts of the formats for ‘event’, and ‘Tournament’ is actually a custom post type.

    And in some parts of the code, some of these are actually hardcoded, for example here:

    Is there a way to add custom formats and add their respective point system? Here is what I’m trying to achieve:

    Can I achieve this functionality with the sportspress_formats filter?

    Thanks in advance ??

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

    (@savvasha)

    Hi there @zacksack,

    You cannot use different point system based on your game format. What you can though is to create different outcomes for each format. The drawback of this is that you will need to assign manual the outcome to your events.

    For example you can create the following outcomes for your wins:
    WIN_Ex for the excibition games,
    WIN_LG for the League Games,
    WIN_TG for the Tournament Games and
    WIN_CGfor your Championsip Games.

    With the same scope you can create the Tie outcomes.

    Your Point equation should be something like the following:
    Points = WIN_EX x 5 + WIN_LG x 15 + WIN_TG x 25 + WIN_CG x50 + DRAW_EX x 2 + DRAW_LG x 10 + DRAW_TG x 15

    Thanks,
    Savvas

    Thread Starter zacksack

    (@zacksack)

    Thanks @savvasha ,

    But how do I create the new custom formats? that’s the main issue.

    Plugin Contributor Savvas

    (@savvasha)

    You can use something similar to the following code:

    function add_custom_event_format($formats) {
        $formats['event']['custom_event'] = esc_attr__('Custom Event', 'sportspress');
        return $formats;
    }
    
    add_filter('sportspress_formats', 'add_custom_event_format');

    Thanks,
    Savvas

    Custom Post Types:

    If you’re looking to create a new type of content (apart from posts and pages), you might want to create a custom post type. You can use the register_post_type function to do this. Here’s an example:

    phpCopy code

    function custom_post_type() { $args = array( 'public' => true, 'label' => 'Custom Format', 'supports' => array('title', 'editor', 'thumbnail'), // Add more arguments as needed ); register_post_type('custom_format', $args); } add_action('init', 'custom_post_type');

    This code creates a custom post type named ‘Custom Format’. You can add more arguments to customize it further.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘I want to add new ‘Formats’ to games’ is closed to new replies.