WordPress.org

Forums

How to add posts without wp-admin? Is there a function? (4 posts)

  1. gbrent
    Member
    Posted 6 years ago #

    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?

  2. 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.

  3. gbrent
    Member
    Posted 6 years ago #

    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.

    Example:

    href----------------- image_id ------image_filename
    http://someplace.com/1 | 1 | file1-gf56.jpg
    http://someplace.com/1 | 2 | file2-dfg45.jpg
    http://someplace.com/1 | 3 | file3-45f645.jpg
    http://thatplace.com/2 | 4 | file4-23ghf23.jpg
    http://hersgdffe.com/3 | 5 | file5-34ghj345.jpg

    So with the above data, I want to make a post with images where all href = 'http://someplace.com/1'. So in the end the post is basically all the images that came from http://someplace.com/1

    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?

  4. gbrent
    Member
    Posted 6 years ago #

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

    http://codex.wordpress.org/Function_Reference/wp_insert_post

Topic Closed

This topic has been closed to new replies.

About this Topic