0

Goal: Ability to automatically create content in WordPress posts/pages.

Goal Details: When a post is created/published, it will automatically create or configure content based on the base data inputs of: Post Title, Category, Tag, Image File Name, Website Name, and or a "select" set of keywords or phrases and a standard set of generic content.

Image of Concpet Automatic Post Creation Concept
Question:

  1. Is there a plugin that will automatically create content "inside" the post editor?
  2. Is there a coded solution that will automatically create content when a post is created?

Process Concept: Below describes the steps & how I envision this process operarting:

  1. An image will be added to a post via media library.
  2. A title is added to post
  3. A category is added to post
  4. A tag is added to post.
  5. Post is published.
  6. RESULT: Automatically a set DISPLAY OF CONTENT will be displayed in the post. On the front end, the content will be displayed. Various labels will automatically display the various keywords based on the image name, post title, category, tag labels, thereby creating a unique post. The rest of the content will be standard.

To help inspire thoughtful discussion & research, the ideas I came up with include the following. However, it still begs the question how in each case & what's the best method.

Possible Ideas/Solutions:

  1. Create a custom Field that automatically produces the content
  2. Create a widget I can click on that will produce the content via short code. Then I I’ll be able to edit the customized set of content (Template 1 or Template 2, etc) from a different area.
  3. Create ability to automatically import a bulk set of posts with content that will automatically adjust to a set of label/keyword identifiers.
0

You can use the transition_post_status action to manipulate the post content at the time when it is published. You just need to add a function like the one below into your theme or plugin:

function post_published( $new_status, $old_status, $post ) {
    if ( $new_status == 'publish' && $old_status != $new_status) {
        //Do whatever you want to the post
    }
}
add_action( 'transition_post_status', 'post_published', 10, 3 );

In this function, $post is a WP_POST object, so you can use it to manipulate the post in all kinds of ways. Adding a string to the top of the content would be a simple as this:

$newcontent = 'the content you generated';
$post->post_content = $newcontent . $post->post_content;

I am not sure what you want DISPLAY OF CONTENT to be. If you just want to display the post meta in some original way, then just editing your template file would be much simpler.

Check out these Codex pages for more info:

WP_Post

Post Status Transitions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.