Alternative to new_to_publish Hook for Custom Statuses

new_to_holding doesn’t exist as a post status transition – you need to use the generic transition_post_status action. Something like (untested): add_action(‘transition_post_status’,’my_holding_function’, 10, 3); function my_holding_function( $new_status, $old_status, $post ) { if ( ‘holding’ == $new_status ) { // do stuff } }

Create WordPress posts from JSON array using plugin in admin

Here I assume your json is an array of object where properties are named like wp_insert_post arguments: ‘post_title’, ‘post_content’ and so on. function process_ajax() { if ( ! isset($_POST[‘nonce’]) || ! wp_verify_nonce($_POST[‘nonce’], ‘mynonce’) ) die(‘error on checking nonce’); if ( ! isset($_POST[‘filepath’]) die(‘no file given’); if ( ! file_exists($_POST[‘filepath’]) ) die(‘invalid file given’); $posts = … Read more

Remove all removed pages from wordpress

You must use wp_delete_post() with second parameter set to true. The post will be completely deleted, not trashed. // Use $args to get the pages you created previously // See https://developer.wordpress.org/reference/functions/get_pages/ $pages = get_pages( $args ); if( $pages ) { foreach( $pages as $page ) { wp_delete_post( $page->ID, true ); } } After that, you … Read more

wp_insert_post custom type and custom taxonomies

Your logic is a little flawed – you run isset checks on fields like title and description, but don’t actually halt the post insertion if they’re not set. You also don’t check the post_tags index, which will never exist because wp_dropdown_categories will use the field name cat unless you set it to something else. Not … Read more

Programmatically create a post once a day

If you look at the documentation for get_page_by_title, the 3rd argument is $post_type, Default: page. Since you are creating a post, you should pass in post as the post type when calling get_page_by_title, like below: if( null == get_page_by_title( $title, OBJECT, ‘post’ ) )

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)