function to write the output of a variable post_title in post_content
-
I have a function that writes the output of a function of a rand_keys + the post_title in post_content, but writing the title but only happens after I click manually on the update button on the post-edit, how do I automate this?
I have a plugin that makes an import of a post automatically, creating a post for me, but I need to copy the title of this post for post_content, and not to getting only appears if I go into all the posts and click update, and he said bad and rand_keys output appears when the plugin creates the new post, but the title appears not written in post_content, then click on the update button and the rand_keys appears again and this time appears post_title in post_content.add_filter( 'wp_insert_post_data' , 'add_string_on_publish' , '999', 2 ); function add_string_on_publish( $post_content, $postarr='' ) { $post = get_post( $post_title ); $input = array(" Neo ", " Morpheus ", " Trinity ", " Cypher ", " Tank ", " the flash "," superman "," wolverine ", " subzero "," scorpion "); $rand_keys = array_rand($input, 2); $mixnames = $input[$rand_keys[0]].$input[$rand_keys[1]]; $post_content['post_content'] .= $mixnames . $title = $post->post_title; return $post_content; add_action( 'publish_post' , 'add_string_on_publish' ); }
I’m using it as a second plugin.
this code works in conjunction with the first plugin to import posts, it is part of the work automatically, it inserts the values ??of several $ mixnames + post_title only do after clicking the update button manually. and also doubles the output with $ mixnames because before clicking the function had injected the output of the variable once.
Thanks.
- The topic ‘function to write the output of a variable post_title in post_content’ is closed to new replies.