Your question asks how to insert a new post into WordPress using SQL. If you really wanted to do that, taking a look at the “wp” database tables and do a standard INSERT – this wouldn’t be hard.
But I’d strongly recommend against doing this – even if you want to create a separate admin dashboard outside of the normal WP-provided one, you should use the core functions/API that they provide. For example, the wp_insert_post function is what you want to use.
I believe you can use/load these functions by including /wp-load.php.
2: I took the content that i wanted to insert, from another table – but you can just set the variables either inside or outside of your statement just set the variable to what you desire –
You can use the Post object:
More info found here.
Your question asks how to insert a new post into WordPress using SQL. If you really wanted to do that, taking a look at the “wp” database tables and do a standard INSERT – this wouldn’t be hard.
But I’d strongly recommend against doing this – even if you want to create a separate admin dashboard outside of the normal WP-provided one, you should use the core functions/API that they provide. For example, the wp_insert_post function is what you want to use.
I believe you can use/load these functions by including /wp-load.php.
I started by exporting the “wp_post” table just to see the structure – then copied the first section and wrote the seccond;
1: Start with a variable you can use for your insert statement ($sql)
2: I took the content that i wanted to insert, from another table – but you can just set the variables either inside or outside of your statement just set the variable to what you desire –
After that, use your standard query: