WordPress.org

Forums

writing custom query (2 posts)

  1. backseatfan
    Member
    Posted 5 years ago #

    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

  2. MichaelH
    Member
    Posted 5 years ago #

    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>";
    }

Topic Closed

This topic has been closed to new replies.

About this Topic