• Resolved floesen

    (@floesen)


    Hi there,

    I’m encountering a problem when adding posts via the wp_insert_post() function:

    Each post starts with an image. Each image has some style, src, alt and title attribute and here occurs some strange behaviour: When adding the post to wordpress using wp_insert_post() the title attribute of the img tag won’t be saved to the database. The alt attribute, which contains the same value as the title is saved properly though.

    If I edit the post in the wordpress editor, add the title manually for one post and then update the rest of the posts using wp_update_post() all other title attributes are properly saved.

    Anyone any ideas why this behaviour occurs and how to fix?

    Thanks in advance & best regards,
    floesen.

Viewing 1 replies (of 1 total)
  • Thread Starter floesen

    (@floesen)

    Hi,

    I fixed it. For some reason it’s crucial that you supply the <img> tag attributes in exactly the same order as they appear in the post editor.

    f.e.:

    <img src=”/wp-content/uploads/example.jpg” alt=”some alt text” title=”the title” width=”400″ height=”300″ class=”some wordpress class (f.e. alignleft)” />

    Hope it might save someone some time ??

    Best regards,
    floesen.

Viewing 1 replies (of 1 total)
  • The topic ‘image titles via wp_insert_post()’ is closed to new replies.