Using of tribe_get_events()

Home Forums Calendar Products Events Calendar PRO Using of tribe_get_events()

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #991314
    Hans-Gerd
    Participant

    Hi,
    I have read the information, for example on the following page

    Using tribe_get_events


    , have spend many time, but found nothing in the forum.
    In which file for example, the following code sample needs to be integrated ? – May be loop.php ?
    Is it possible to show me a complete example or a url with a complete example ?

    // Retrieve the next 5 upcoming events
    $events = tribe_get_events( array(
    ‘posts_per_page’ => 5,
    ‘start_date’ => new DateTime()
    ) );

    Sorry for so many questions
    Cheers
    Hans-Gerd

    #991417
    George
    Participant

    Hey @Hans-Gerd,

    Thanks for reaching out!

    The tribe_get_events() function is designed to be used in basically any file where you’d need to use it – you can use it in your theme, in other plugins, anything really.

    Can you elaborate on your goals for using this function, and provide some specific details about what you want to achieve? We might be able to provide some extra context and better examples from there 🙂

    Thanks,
    George

    #991450
    Hans-Gerd
    Participant

    Hey George,
    many thanks for your quick reply.
    It’s difficult, but I will try:
    The events should be shown in the following order
    1. Events that take place exactly on that day
    2. Current events, which start at this day
    3. Series Dates (Permanent Dates) on this day
    Events, do not start that day, should not be shown.

    I have tried to override the template in my theme by creating a file at [your-theme]/tribe-events/list/loop.php, but it does not work properly

    Many thanks for your help

    Cheers
    Hans-Gerd

    #991483
    George
    Participant

    Hey Hans-Gerd,

    Thank you for the additional information. It’s unfortunately a bit hard for me to understand exactly what you mean, but I think you’re trying to show events that are only happening “Today” (which would obviously change each day 🙂 ).

    For some examples of using specific dates with tribe_get_events(), check out this article here → https://theeventscalendar.com/knowledgebase/custom-event-queries/

    You can use the PHP date() functions to specify a start_date of “today” at 00:00 and an end_date of “today” at 23:59 – this will get events that are happening today.

    This date() page is linked to in that article above, but you can check it out here for more information on how to do this → http://php.net/manual/en/function.date.php

    I hope this information helps!
    George

    #991493
    Hans-Gerd
    Participant

    Hey George,
    unfortunately this is not what I mean.
    I had already read the information on the website https://theeventscalendar.com/knowledgebase/custom-event-queries/ earlier. But the central point is that I do not know exactly where the code snippets that are described therein, must be integrated.
    It would be very helpful for me, if I had it a complete example, for example, a modified loop.php.

    In other words: The problem for me is not to understand the programming of the code snippets, which are described on the above website, but integrating them into a PHP file (which ? – where ?).

    Sorry, but it’s also difficult to describe, in fact.

    Many thanks for help

    Cheers

    Hans-Gerd

    #991902
    George
    Participant

    Hey Hans-Gerd,

    I’m sorry for misunderstanding your questions – as you mention, some of these details are hard to communicate.

    The unfortunate thing is that I don’t quite know where you will need to paste your code, either. This is one of the main components of customizing things, and depends entirely on your site, what your site needs, etc.

    Generally speaking, loop.php is already a loop of events, so you don’t need to add extra calls to something like tribe_get_events() here.

    If you’re trying to show today’s events somewhere in your theme, you will need to head into your theme code and find the right place there – this is not something we would know from our end, unfortunately.

    Let me know if this clarifies anything, or if you can specify a bit more about what exactly you are trying to build.

    Thank you for your patience, I’m sorry about the difficulties in communication here but will continue to try to help where appropriate (although, please do keep in mind that we do not support customizations here).

    Thank you,
    George

    #992023
    Hans-Gerd
    Participant

    Hey George,
    I’m very sorry that I could not formulate such clear my questions. My English skills are not so sufficient to formulate these questions well.
    In fact, I had always assumed that I have to create the changes in the source of the events calendar.
    But through your kind help I have now realized that the changes are to be realized in the theme.
    I think that I can implement the changes so well, as I imagine it.

    Thanks again for the great help. Should I have any further questions on this subject, I will contact you again.

    All The Best

    Hans-Gerd

    • This reply was modified 10 years, 9 months ago by Hans-Gerd.
    #992384
    George
    Participant

    No problem Hans-Gerd! Thanks for your patience and for making the effort to communicate here.

    We cannot help much with custom code questions, but I will close up this thread and keep my eyes out for future threads from you regardless and will help as much as I can! 🙂

    Best of luck with your site,
    George

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Using of tribe_get_events()’ is closed to new replies.