Get Cost

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1144491
    Thaddeus Ruszkowski
    Participant

    Hi, 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>";
    				}?>
    #1144582
    Geoff
    Member

    Hey 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!
    Geoff

    #1144601
    Thaddeus Ruszkowski
    Participant

    Thanks. 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
    #1144655
    Geoff
    Member

    Hi 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

    #1144659
    Thaddeus Ruszkowski
    Participant

    yeap thank you. i will test.

    #1144662
    Geoff
    Member

    Excellent, thanks Jordan!

    #1145022
    Thaddeus Ruszkowski
    Participant

    category 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.

    #1145093
    Geoff
    Member

    Hey Jordan,

    Does it work if you replace the ID with the $event variable instead:

    tribe_get_cost( $event );

    Geoff

    #1145160
    Thaddeus Ruszkowski
    Participant

    Thanks

    #1145330
    Geoff
    Member

    My pleasure!

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Get Cost’ is closed to new replies.