nutsmuggler
Member
Posted 5 years ago #
Hi folks.
I am tweaking a plugin that inserts posts through a query.
I have been able to insert title, date, the 'draft' status, but I realised that the post_name and guid field are not automatically generated. I suspect that there are a function to generate this fields from the title and ID, but I could not find them in the wp code.
Can you help me?
sanitize_title() generates the post_name from either the post name field or the title field, depending on what you pass to it.
You'll also need to check the database to ensure that the post_name you're adding is unique, since it's often included in the URL. If it's not, you'll need to do some clever things with adding suffixes.