tax_input in wp_insert_post partly not working
Try to append it in array, like this: see this: Insert post with custom taxonomy and post meta data ‘tax_input’ => array( “programmas” => array(‘Modern Family’), “zenders” => array(‘ABC’), ),
Try to append it in array, like this: see this: Insert post with custom taxonomy and post meta data ‘tax_input’ => array( “programmas” => array(‘Modern Family’), “zenders” => array(‘ABC’), ),
Goal: Make a POST request to the WordPress API Indeed, make your POST request to example.com/wp-json/wp/v2/posts. Make sure pretty permalinks are turned on! with new post information. This would be the information being POST‘d, and should take the same format as when going into wp_insert_post Take the new post information, validate it WP will do … Read more
This is what ended up working for me: meta1='{“Length”:’ meta2=’,”Height”:”‘ meta3='”}’ while IFS=$’\t’, read -r col1 col2 col3 col4 col5 || [ -n “$col1” ] do \ meta=$meta1 meta+=$col4 meta+=$meta2 meta+=$col5; meta+=$meta3 And for meta_input line –meta_input=$meta \
If you are trying to fire your function when the WordPress Importer runs, there are a few filters and action hooks available. From the plugin documentation: import_start: occurs after the export file has been uploaded and author import settings have been chosen import_end: called after the last output from the importer https://wordpress.org/plugins/wordpress-importer/
Can you try to wrap you wp_insert_post call like bellow: kses_remove_filters(); //This Turns off kses $post_id = wp_insert_post( $my_post, true ); kses_init_filters(); //This Turns on kses again So I tried your code with my method and it perfectly worked. Here is what I did. $title = “My news”; $content=”<p> <img src=”https://wordpress.stackexchange.com/questions/368433/img-link”> </p> <p> Hi, this … Read more
Try to use wp_update_post() in place of wp_insert_post for update. $id = wp_exist_post_by_title($post[‘post_title’]); if($id !== false) { $post[‘ID’] = $id[“0”]; // Create Post $post_id = wp_update_post( $post ); } else { $post_id = wp_insert_post( $post ); }
You just add the content to your initial array. The most simple way is using the titles as array indices like this: $pages = [ ‘Login’ => ‘Some content’, ‘Dashboard’ => ‘Some other content’ ]; foreach ( $pages as $title => $content ) { if ( get_page_by_title( $title ) ) { continue; // skip this … Read more
Looking at your if-else block, I see there’s a $post_id variable, so if it’s the ID of the post that you want to assign to the user you’re creating, then you could just call wp_update_post() in your else block, i.e. right after you create the user. So just replace the wp_insert_user($userdata); in your code with … Read more
page load is not affected […] and the //METADATA is echoed/displayed immediately? With your current setup, that is not possible. In order to display immediately, you need the data. To get the data, you need to wait. Possible solutions are: Fetch the data before (e.g. via Cron) and populate the DB with the info. -> … Read more
You shouldn’t be getting this problem, I have a site with more 10000 posts using this function all the time and everything works fine. Try running a cleanup in your database to see if things get better.