Ready to get started?Download WordPress


writing custom query (2 posts)

  1. backseatfan
    Posted 4 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
    Posted 4 years ago #


    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