Support » Fixing WordPress » writing custom query

  • backseatfan

    (@backseatfan)


    I created a custom table called CustomPosts in my wordpress database. I’m trying to write a query to pull the records from this table but WordPress doesn’t like how I’m doing it. I know this has to be documented somewhere but I can’t find a page. Can anyone assist? Thanks

Viewing 1 replies (of 1 total)
  • MichaelH

    (@michaelh)

    wpdb

    If your table is called “customposts” then

    $results = $wpdb->get_results("SELECT * FROM customposts");
    
    foreach ($results as $result) {
    	echo "<pre>"; print_r($result); echo "</pre>";
    }

Viewing 1 replies (of 1 total)
  • The topic ‘writing custom query’ is closed to new replies.