• Resolved apinis

    (@apinis)


    Hey there!

    Would it be possible to make event website url as buy tickets button? We have third party ticket sellers and there is no option to add such link elsewhere.

    Or maybe I can somehow remake additional field type url as button?

    p.s. great work on the plugin! I am looking now at the funcionality and planning to buy the pro version.

    • This topic was modified 4 years, 3 months ago by apinis.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Below are a couple code snippets I whipped up that will utilize the built-in Event Website URL field for a “Buy Tickets” button.

    <?php
    /* Change label of website URL from the URL itself to "Buy Tickets" */
    add_filter( 'tribe_get_event_website_link_label', function( $label, $post_id ) {	
    	// Check if the label equals the website URL
    	if ( $label === tribe_get_event_website_url( $post_id ) ) {
    		$label = "Buy Tickets";
    	}
    	
    	// Always return the $label
    	return $label;
    }, 10, 2 );
    
    /* Add a "button" CSS class to the website link */
    add_filter( 'tribe_get_event_website_link', function( $html ) {
    	// Customize the button class here. Might be 'btn' or something else
    	$button_class = 'button';
    
    	// Insert the class attribute and value defined above.
    	$html = str_replace( '<a', '<a class="' . $button_class . '"', $html );
    	
    	// Always return the $html;
    	return $html;
    } );

    There are two snippets above. The first will change the text to “Buy Tickets” instead of the URL itself.

    The second may not be necessary if you’re handy with CSS. It’s just a helper function to add a “button” class to the link, which is commonly included in WordPress themes although not guaranteed.

    So that part might not do anything depending on your theme. If you could share your website URL, I could help you cross the finish line as far as the styling goes.

    These are PHP code snippets so please search for “adding php snippets to wordpress” for further guidance if you’re not familiar with the process. The free https://ww.wp.xz.cn/plugins/code-snippets/ plugin is a popular choice.

    The “downside” is that it assumes every event will be set up like this. Might not be ideal if some event tickets would be free, or if tickets were distributed on your WordPress site, for example.

    Maybe that’s okay with your use case, just wanted to mention for you and potentially others reading this post.

    Hope that helps and let me know how it goes.

    Best regards,
    Leland

    Jaime

    (@jaimemarchwinski)

    It’s been a while since this thread has been active, so I’m going to go ahead and close it for now.

    Feel free to open up a new one if anything else comes up.

    Have a wonderful day!

    Thanks,

    Jaime

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Adding third party ticket seller button’ is closed to new replies.