• Hi,

    im’ trying to make a page with dynamic content, loaded via an endpoint (json, xml or whatever…)

    Basic usage, i want to add some pages informations for all the countries, more than 220 countries, it’s quite painful to add them as a “static page” (besides, the data can be updated daily for some of the countries).

    What i’m trying to do, is to make a single “structure” page, and via an endpoint, fill some DIVS with the data reguarding the country selected (and recognizable in the URL)

    I saw that gutenberg can manage dynamic blocks but i think it’s not the proper solution to do this.

    Does anyone has the same issue ?

    Best regards

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    If you are getting data from the API, you’ll want to use JavaScript or jQuery to fetch the data and place it into elements on the page. Use JSON.parse() to convert JSON into a usable object.

    A completely different approach, if the data is within your WP database, would be to use a custom page template to directly query for the data and use it in page output, completely bypassing the API. Of course, if the API is from a third party source this won’t work very well. You could still use PHP to fetch API data, then relay it to the browser. This may be necessary if a secret API key is needed to get the data, otherwise you’re better off letting the browser fetch the data via JavaScript.

Viewing 1 replies (of 1 total)
  • The topic ‘Dynamic content’ is closed to new replies.