Support » Themes and Templates » displaying custom database data on site

  • I have a table with data that I would like to display in various areas of my blog. I’m having difficulty with figuring out how to get the data from the mysql database to my site. I’ve tried creating a custom function in my theme file but I seem to get errors when I try and change the database. How can I get data from the database and be able to display it in posts and pages? Do I need to create custom functions to send my own queries?

Viewing 1 replies (of 1 total)
  • After creating a table in the WordPress Database called “Custom”
    Write a function to this effect.

    // function CustomFunction($variable)
    // {
    // Global $wpdb; $Custom = $wpdb->get_row(‘
    // SELECT * FROM wp_custom WHERE fieldname = “‘.$variable.'”
    // ‘);
    // echo $Custom->fieldname;
    // }

    This pull will read all fields into the $Custom variable array and each field name can be accesed as part of that array using $Custom->fieldname;

    To acces this functionality inside a post you will need a plugin do search on the forum for this.

Viewing 1 replies (of 1 total)
  • The topic ‘displaying custom database data on site’ is closed to new replies.