Sanitize WordPress Array Input?
I’m not completely sure what you mean to do, but are you looking for sanitize_text_field? $array = array_map( ‘sanitize_text_field’, $array );
I’m not completely sure what you mean to do, but are you looking for sanitize_text_field? $array = array_map( ‘sanitize_text_field’, $array );
If think you were using the wrong filter, please try using ‘single_template’. I assume you have created a plugin to create your custom post type. In the plugin folder you have a “templates” folder where you put the single page template called “palaver_single.php”. function palaver_single_mapping($single) { global $post; if ( $post->post_type == ‘palaver’ ) { … Read more
Cannot insert HTML content even removing kses filters
This function is completely unnecessary, and can be replaced with the official WP function called media_sideload_image: media_sideload_image( string $file, int $post_id, string $desc = null, string $return = ‘html’ ) for example: $new_image_id = media_sideload_image( “https://example.com/image.png”, $post_id, “Toms great picture”, ‘ID’ ); https://developer.wordpress.org/reference/functions/media_sideload_image/ Don’t forget to check the result, if this fails it will return … Read more
I have managed to solve using the add_post_meta function instead of the meta_input property of the $postarr argument of the wp_insert_post function, as follows Instead of this $entry = [ “post_title” => “Some post title”, “post_content” => “Some post content”, “post_type” => “name_of_custom_post_type”, “post_status” => “publish”, “meta_input” => [ “some_meta_key” => “Some value”, “another_meta_key” => … Read more
wp_set_object_terms() custom taxonomy not working correctly when using insert post
XML FOLDER – wp_insert_post – how to assign XML variables to post
You are doing this to add posts to the $data array: $data = … This is not how you add something to an array. You want to append, not assign. Think of it like writing a list of 5 things, where for each item you throw the list in the trash, get a new piece … Read more
wp_insert_post() crashing website
I will give you a simple example, which you can modify for your purpose. save_weather_field This function will add/update/delete any post meta (in case you will decide to add more weather fields). We will use it inside post save action below. function save_weather_field($post_id, $key, $value) { //new value we pass in this function $new_meta_value = … Read more