Forums

Generating post_name and GUID value (2 posts)

  1. 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?

  2. maerk
    Member
    Posted 5 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic