Title: Adding records via SQL
Last modified: August 20, 2016

---

# Adding records via SQL

 *  [jmastrom](https://wordpress.org/support/users/jmastrom/)
 * (@jmastrom)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/adding-records-via-sql/)
 * I added 2 records for a custom post type manually, and 100 via a php script. 
   The database rows look exactly the same for bot the manual and scripted entries(
   except for the IDs)
 * All show up in my custom view in the WP Admin… but only the two manually entered
   show up on the actual WordPress page meant to show all from the custom post type.
 * Please help.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/adding-records-via-sql/#post-2453505)
 * As a guess, I would look for records in postmeta (and possible other tables) 
   that are there for the 2 manual ones and missing for the script ones.
 *  Thread Starter [jmastrom](https://wordpress.org/support/users/jmastrom/)
 * (@jmastrom)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/adding-records-via-sql/#post-2453511)
 * Thanks!
 * It was really strange. All the term_relationships and post_meta was there. I 
   have no idea what fixed it.
 * I ended up figuring out how to use wp_insert_post() and add_post_meta(), but 
   I just can;t believe that their is a difference in how they are inserted
 * Now, If I can only figure out how to replace:
    $term_values=array(1,2,3,); foreach(
   $term_values as $_in){ $sql=”INSERT INTO wp_term_relationships (object_id, term_taxonomy_id)
   VALUES($db_row, $_in)”; $r_=mysql_query($sql); }

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Adding records via SQL’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [jmastrom](https://wordpress.org/support/users/jmastrom/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/adding-records-via-sql/#post-2453511)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
