• Hello all,

    Apologies if this isn’t the correct forum for this but I’m a bit unsure on the approach to this.

    The theme is entirely custom so any suggestions are all welcome, I have no real limits.

    I’m attempting to make a live events site. I would like to use the standard build-in WP navigation system and pages to generate most of the site content.

    The part that I’m unsure on the best practice of is to implement pages where I wish to display custom data. The data is being retrieved from a remote server. The data is for the events and the speakers and is constantly updated. The display of the data is locked in as well so the WP admin won’t have any control over that data, or the display.

    I only know of 2 ways at the moment..

    1) Create a custom page template for every nav item (e.g. page-custom1.php .. page-custom999.php) and point every single link in the navigation their respective custom page, or perhaps append some URL data to a single custom page to tell it what data should be displayed.

    2) Write a plugin (I’d rather not stick it in functions so I can re-use it) to add a filter and create a short code for the various API calls. Then point each navigation item to a standard page and insert the correct short code.

    I feel like I might be missing a way of implementing this. The important parts are that I can use the standard WP navigation system just how it currently works, and the display of the remote APIs data is inside the current WP theme.

    Any tips very much appreciated!

Viewing 6 replies - 1 through 6 (of 6 total)
  • This is an interesting problem, and you are definitely right to think about how you want to implement this.

    Having a unique page/url for each event can be very helpful for SEO purposes.

    You don’t need a custom page template for every nav item – your #2 idea is pretty good. You can make a page template that uses a custom field to pull in this data, or you can use a shortcode as you suggest.

    I’ve done the shortcode method on this site: https://emlentertainment.com. Each page has a shortcode that marks the artist or event for that page, which means that our SEO folks can add helpful text around it: https://emlentertainment.com/the-grateful-dead-fare-thee-well/

    The shortcode is something like this: [get_events artist=’grateful dead’]

    The list of events and tickets comes from a third-party API.

    When you click on get tickets, the page is a custom page template that has an event ID as a parameter, so when an event is over, we don’t have to do anything to remove it.

    Thread Starter omii

    (@omii)

    Thanks very much for your input.

    Do you feel this is working for you? Any areas you have noticed is difficult from this implementation?

    If you had to do this again would you do it the same way?

    Good questions! I’ll write up some more in a bit.

    Do you have a plan for how this site will be maintained?

    Thread Starter omii

    (@omii)

    The site is fairly simple, just as explained. The events are live speakers talking to audiences in a convention context.

    Multi-Site WordPress seems pretty ideal for this. Deployment is as easy as adding a new site to the network admin, customize a child theme to match the conference and use the same plugin to list speakers and events. I’ll just need to make sure I make it a multisite friendly plugin so the API each site in the multisite accesses different data.

    The data coming from the API will be managed by a custom admin the conference admins can manage.

    Pretty straight forward and a bit like reinventing the wheel but I’m just hoping to merge the API data with basic WordPress ease.

    Okay, I’m back and I have a bit more time to write.

    This approach works well for us, because it means that I (as the programmer) doesn’t have to do anything to create new pages with content for different artists. We have a marketing person who does this using shortcodes. They know how to create new pages/posts, add things to menus, etc.

    Some of the issues that we run into is when there’s a problem w/ the third-party service itself. In that case, no content shows up for the artist (instead, they get a “Come back later” message). TicketNetwork doesn’t have these problems as much as other services I’ve tried to integrate into WordPress, so it’s not a big deal.

    For this site, the ticket inventory and available events is massive, so other approaches would have been more complicated and fragile. We are highlighting certain artists and events, to make sense of the mass of data.

    Other approaches when getting data through an API would be to cache some of the info, or import into posts, and then call the API only when you need some real-time information.

    If your API provider charges you by the call (such as with Twitter and Google and other freemium providers) you will want to cache the information so you don’t make 1 call to the API per page visit.

    Thread Starter omii

    (@omii)

    We’re like-minded on the shortcodes approach because while I hesitate to give them control over a page in a way they could easily make mistakes, the flexibility is just a bit more important.

    The display of the events (title, location, date, etc) and speakers (name, title, credits, bio, etc) are all the same regardless which page they’re displayed on. So although there’s several pages that list events and the events are different, it’s just re-using the same code to display it from the filter. Modular and testable.

    I agree that with WP itself needing to initialize itself, then adding the remote API call, this could stall out and get into a “no data received folks, sorry” situation. Luckily it’s all built on Amazon cloud services which appear to be lightning quick so far.

    Caching is a tricky subject. Event admins of course want to see their changes instantly on the site but you’re right, with systems like Amazon you do pay for what you use. I’ll be utilizing localStorage as much as I can, with a fairly quick expire (5min or so).

    It’s nice to see that the approach we’re taking here is pretty similar so it gives me some extra confidence that this is the right way to go. WP content authoring ease with custom data where it belongs.

    Thanks for all your responses!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Best practice – Integrate data from remote site (API)’ is closed to new replies.