• Resolved spaaarky13

    (@spaaarky13)


    Ok so continuing partially from this thread. I’ve been able to get the thumbnail’s working. So here’s my code at the moment:

    <?php
    include_once"wp-config.php";
    include_once"wp-load.php";
    include_once"wp-includes/wp-db.php";
    
    $my_post = array();
      $my_post['post_title'] = 'hi';
      $my_post['post_content'] = 'This is my post.';
      $my_post['post_status'] = 'publish';
      $my_post['post_author'] = 1;
      $my_post['post_excerpt'] = 'excerpt';
    wp_insert_post($my_post);
    echo get_the_ID();
    
    add_post_meta(233, 'thumbnail', 'https://somedomain.com/asdadsafsdafsf.jpg');
    ?>

    Basically the problem I have is how I can get the id that gets created in the wp_insert_post part and use in in the add_post_meta.

    Any ideas?

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘wp_insert_post and add_post_meta’ is closed to new replies.