Support » Plugins » How to add posts without wp-admin? Is there a function?

  • I am pulling in thousands of pictures per day into Pages on my blog. Each Page is a template that when called, will check a custom DB for pictures and display them as thumbnails. When a person clicks on one of these thumbnails I would like them to be directed to a post where they can make comments over that one picture. I would like these comments to be stored in the wordpress DB and show up in the admin panel so I can review them.

    So, what I think needs to happen is, I need to make a post for each image that I pull in. I have only made posts with wp-admin and never programaticly. Is there something simple I can do such as…
    <?php add_post(‘title’,’permlink’, ‘post_text’, ‘date, ‘tags’); ?>

    Or do you have another suggestion on how I should go about this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Samuel Wood (Otto)

    (@otto42) Admin

    If you are adding pictures via the normal WordPress uploader mechanism, then these are called “attachments” and they get a post of their own automatically. You can create custom theme templates for them (“image.php” in the theme) and yes, they can have comments just like any other post.

    However, if you’re putting pictures in via some other method, then this doesn’t all happen automatically. If you have some kind of custom code, then look closer at the wp_insert_attachment() function.

    Well I do have custom code. All it does is pull in an image, give it an ID, date and other info and sticks it in a separate DB. It is saved to the Hard Drive and recalled later….WP has nothing to do with these actions. When I display the images they are all on a custom template Page and I just find them in a directory where I put them.


    href—————– image_id ——image_filename | 1 | file1-gf56.jpg | 2 | file2-dfg45.jpg | 3 | file3-45f645.jpg | 4 | file4-23ghf23.jpg | 5 | file5-34ghj345.jpg

    So with the above data, I want to make a post with images where all href = ‘’. So in the end the post is basically all the images that came from

    If I do the wp_insert_attachment() way… I will have 3 separate posts when I only want one.
    Is there a function like wp_insert_attachment() that is more like insert post?

    here is the way to insert a post by giving it your own data without the form

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to add posts without wp-admin? Is there a function?’ is closed to new replies.