Home › Forums › Calendar Products › Events Calendar PRO › Add same Text to all cost prices in event title on single events page
- This topic has 5 replies, 2 voices, and was last updated 7 years, 10 months ago by
ftww.
-
AuthorPosts
-
May 25, 2018 at 6:38 am #1538700
ftww
ParticipantHi There,
I would like to add the text “Price:” before the amount shown for ticket price in the event details subheading heading on a single events page.As per this thread – https://theeventscalendar.com/support/forums/topic/add-text-to-cost-field/
Jennifer who replied mentioned 2 ways to do this and I would appreciate being pointed in the right direction of where to add the code and text for this.
Thanks in advanceMay 27, 2018 at 5:04 pm #1539824Jennifer
KeymasterHello,
Thanks for reaching out!
You can use a modified version of the snippet that I linked to in that post to accomplish this, something like:
function tribe_price_text_cost_field( $cost, $post_id ) {
$event_price = esc_html( get_post_meta( $post_id, '_EventCost', true ) );
if ( tribe_is_event() && is_single() && $event_price > 0 ) {
return "Price: " . $cost;
} else {
return $cost;
}
}
add_filter( 'tribe_get_cost', 'tribe_price_text_cost_field', 10, 2 );You’ll want to add that to the functions.php file of your child theme. Please note that we are limited in the amount of support that we can provide for customizations, but we do try to point users in the right direction when we have the bandwidth to do so 🙂
Let me know if you have any questions!
Thanks,
Jennifer
May 29, 2018 at 4:25 am #1540606ftww
ParticipantHi Jennifer,
That worked great and thanks for your assistance. the only thing is that it also adds it in the details block below the events also where there is already a header. I do understand that this is getting in to the area of customisations – on the other hand, I’d argue that having cost: or price: included in the description would look a lot better overall as a customisation!!!.
So if there is a way for it to only appear in the title that is straightforward that would be really great!
Thank youMay 29, 2018 at 12:25 pm #1541158Jennifer
KeymasterHello,
Thanks for the feedback! You can instead do a template customization – our themer’s guide has instructions on doing this, and the template you’ll want to edit can be found at wp-content/plugins/the-events-calendar/src/views/single-event.php. Look for this line:
<span class="tribe-events-cost"><?php echo tribe_get_cost( null, true ) ?></span>You can add the text in like this:
<span class="tribe-events-cost"><?php echo "Price: " . tribe_get_cost( null, true ) ?></span>This will only add it to the price at the top of the page. I hope this helps!
May 31, 2018 at 3:45 am #1542653ftww
ParticipantSuper – thanks – worked a charm!
May 31, 2018 at 11:43 am #1543256Jennifer
KeymasterPerfect! I’m glad this worked for you. I’ll go ahead and close out this thread since it’s been marked “Resolved”, but please feel free to open up a new one if you have any other questions!
June 22, 2018 at 9:35 am #1559336Support Droid
KeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘Add same Text to all cost prices in event title on single events page’ is closed to new replies.
