preventing the duplicate wp_insert_post
if no match found for tablerecid insert the post, else add post meta if (!preg_match(‘/tablerecid/’, $data[ ‘post_content’ ])){ wp_insert_post } else { add_post_meta }
if no match found for tablerecid insert the post, else add post meta if (!preg_match(‘/tablerecid/’, $data[ ‘post_content’ ])){ wp_insert_post } else { add_post_meta }
In case that I have understood your (very brief) question and you’re not actually talking about the post_tag-taxonomy then you have wp_insert_term(), which is the underlying API function. Edit As to the comment, there’s the need of meta data for a term and administrator approval. WordPress currently has no native way of adding meta data … Read more
Have you tried: wp_set_object_terms( $postId, array( ‘obrazek’), ‘rodzaj’ ); wp_set_object_terms and wp_set_post_terms take the same arguments. wp_set_post_terms even uses wp_set_object_terms internally. The main difference being that you used an array in the one that worked, and you didn’t use an array in the one that didn’t work.
If you do not pass a date to wp_insert_post(), get_gmt_from_date() is called. And look at that function’s content: function get_gmt_from_date($string, $format=”Y-m-d H:i:s”) { preg_match(‘#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#’, $string, $matches); if ( ! $matches ) return date( $format, 0 ); $tz = get_option(‘timezone_string’); if ( $tz ) { date_default_timezone_set( $tz ); $datetime = date_create( $string ); if ( … Read more
This is about a year over due. I have had a similar thing happen on my new word press install. Creating pages dynamically and getting incremental numbers on the slug names. During this process I realised that the original slug would access the last one. ie. ../../dynammic-page would access ../../dynamic-page-4 The solution was in the … Read more
If I understand well you want use wp_insert_post to create a post of ‘car’ type, and the when this post is created, use the id of this post as parent for another post, but of another post tpye: ‘user’. This is possible, but note that if one post type is hierachical your permalinks will break. … Read more
Yep, wp_insert_post will call save_post, hence the closed-loop. Use remove_action( ‘save_post’, ‘generate_ceu’); $pid = wp_insert_post($new_post); add_action( ‘save_post’, ‘generate_ceu’);
Higher-level API functions like this in WP typically do the $wpdb->prepare() call to protect against MySQL injections. As for content by default comments do allow HTML, however it isn’t just anything. If you examine default-filters.php there are quite a few sanitizing functions hooked to processing comment data, including wp_kses_post() which limits HTML to white listed … Read more
After asking this question in several places and not getting a solution, I found the solution this morning myself. Instead of hooking the function send_email_on_pending_post_creation to the “wp_insert_post” action, you need to hook it to the “add_attachment” action which occurs AFTER the post is inserted and when the attachment is added to the post. You … Read more
You hook the tr_change_show_title to a filter inside the function itself, that can make a infinite loop. All the stuff removing/adding actions and filters inside the functions should be deleted; instead check if the post data should be updated or not. In your case you should check if the title has the value you desire … Read more