Tag Info

New answers tagged

0

I found the solution by the comment from birgire what tells to use wp_defer_term_counting() as follows: if( ! $errors ) { // Set wp_defer_comment_counting(); wp_defer_term_counting( true ); foreach( $lines as $line ) { // Import post $args = array( 'post_title' => ...


1

As pointed out by Otto - it's going to cause an infinite loop. The solution is to unhook your function before you do a wp_insert_post and then hook it back on afterwards. remove_action('save_post', 'wysiwyg_save_meta'); wp_insert_post($postArgs); add_action('save_post', 'wysiwyg_save_meta');


1

Hate to point out the obvious but: add_action('save_post', 'wysiwyg_save_meta'); function wysiwyg_save_meta(){ ... wp_insert_post($postArgs); ... } That's an infinite loop. The save_post action is called at the end of wp_insert_post. So you're just looping around in circles, digging an ever deeper hole of calling your function and then ...


0

For serializing and unserializing Data in Wordpress, you can use maybe_unserialize and maybe_serialize. If you want to handle the data and add/change values, you could use something like this: $metaarray = maybe_unserialize(get_post_meta($post_id,'_ait-dir-item',TRUE)); //now $metaarray has an array, if it is serialized. If not, $metaarray has a string. ...


0

You should first run the wp_insert_post() which will return the post ID. Then use that post ID to add your custom fields. Use add_post_meta() to add the custom fields. $post_id = wp_insert_post( $args ); add_post_meta( $post_id, 'longitude', $my_long ); add_post_meta( $post_id, 'latitude', $my_lat );


0

Don't user custom fields to fix it, you should better try this: if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ){ $post_id = wp_insert_post( $my_post ); }


0

This is theoretically possible. While there is no explicit way to do this in post insert/update process, all queries go through query filter before being run on database. Practically this is a no go. The level of complexity in WP's handling of post querying is incomprehensible and full of edge cases. There is no easy telling how much would break over ...



Top 50 recent answers are included