Pull information from remote database and store in post


I was wondering if there was an easy way to pull information from a remote database and store the results in a page or post?

I can connect to the remote source no problem and pull the data and format it into a table etc no problem. The issue I have is the database is dynamic and I want to to fix the results at the time of creating the page or post and not pull a new set of results everytime the page or post is opened.

Any help would be much appreciated.


  • Patrick
    • Support Monkey

    Hi there @Dan

    Welcome to WPMU DEV, glad to have you aboard!

    It sounds like you're pulling in data from an external database, and displaying that raw data in an existing page, perhaps in an iframe?

    To ensure that your data remains static on your WordPress page/post, the data should be used to actually create a new page or post. You'll want to bone up on the wp_insert_post function for that:

    Once your data has been used to create a WP page or post, that post will remain static every time it is viewed unless intentionally updated by you.

    Please let us know if this helps, and don't hesitate to post again if you need to.

  • Dan
    • Flash Drive

    Thanks for this, I probably did not make myself clear enough. I am connecting to the other database using new wpdb connection and pulling the information from a custom table. The data in the custom table changes daily which I display on a page using a shortcode this is great because it automatically updates as and when the data changes.

    However, there are occasions when we want to write a post and talk about the data for a specific day. If I use the shortcode the data displayed changes as the data on the remote database changes. What I would like to do is create a shortcode that will pull the data (for today) and not change when the data is updated tomorrow...hope this is a little clearer?

  • Anang
    • New Recruit

    Hi @Dan

    Trying to help here :slight_smile:

    Is the data on remote database have field when it inserted ? If not, it's possible to add "date_inserted" field ? And in shortcode we can filter the data by date_inserted if adding a field is possible :slight_smile:

    Let me know what do you think :slight_smile:

    Best Regards

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.