Home › Forums › Calendar Products › Events Calendar PRO › Get Cost
- This topic has 10 replies, 3 voices, and was last updated 9 years, 9 months ago by
Thaddeus Ruszkowski.
-
AuthorPosts
-
July 26, 2016 at 9:56 pm #1144491
Thaddeus Ruszkowski
ParticipantHi, I made list of events. but i need it by specific event category and need show cost. here is what i made, please help.
<?php $events = tribe_get_events( array( 'posts_per_page' => -1, 'start_date' => date( 'Y-m-d' ) ) ); foreach ( $events as $event ) { echo "<h4>$event->post_title</h4>"; }?>July 27, 2016 at 7:29 am #1144582Geoff
MemberHey Jordan and welcome to the forums!
Good question — you can use the tribe_get_cost() function to fetch the event cost. So that would look something like this:
<?php $events = tribe_get_events( array( 'posts_per_page' => -1, 'start_date' => date( 'Y-m-d' ) ) ); foreach ( $events as $event ) { echo '<h4>$event->post_title</h4>'; tribe_get_cost(); }?>Cheers!
GeoffJuly 27, 2016 at 7:42 am #1144601Thaddeus Ruszkowski
ParticipantThanks. Right now event can add one cost. can make 2 costs there? i mean add another field for cost. also you didn’t tell me how to filter category. thank you 🙂
-
This reply was modified 9 years, 9 months ago by
Thaddeus Ruszkowski. Reason: category missing
July 27, 2016 at 8:29 am #1144655Geoff
MemberHi Jordan,
There is only a single cost field to display, unfortunately.
You can wrap that query in a conditional the searches for a specific category. For example, something like this:
<?php $events = tribe_get_events( array( 'tribe_events_cat' => 'featured' // or whatever the category slug is 'posts_per_page' => -1, 'start_date' => date( 'Y-m-d' ) ) ); // The query code } ?>Does this help get you started? Please let me know. 🙂
Geoff
July 27, 2016 at 8:30 am #1144659Thaddeus Ruszkowski
Participantyeap thank you. i will test.
July 27, 2016 at 8:32 am #1144662Geoff
MemberExcellent, thanks Jordan!
July 28, 2016 at 1:29 am #1145022Thaddeus Ruszkowski
Participantcategory filter work fine. but tribe_get_cost() not work. if i manually add event id then it show cost. example tribe_get_cost(45);
so it work if we put event id. there have way to get event id in the loop?
Thanks for the help.July 28, 2016 at 7:38 am #1145093Geoff
MemberHey Jordan,
Does it work if you replace the ID with the $event variable instead:
tribe_get_cost( $event );Geoff
July 28, 2016 at 9:55 am #1145160Thaddeus Ruszkowski
ParticipantThanks
July 28, 2016 at 2:31 pm #1145330Geoff
MemberMy pleasure!
-
This reply was modified 9 years, 9 months ago by
-
AuthorPosts
- The topic ‘Get Cost’ is closed to new replies.
