Notes about WordPress Gutenberg themes development.

  • Programmatically managing content

    Read more

    Creating

    $args = array(
    	'post_type'	=> 'eco__cpt_ressource',
    	'post_title'	=> get_the_title( $attachment_id ),
    	'post_status'	=> 'publish',
    	'post_author'	=> get_current_user_id(),
    	'post_date'	=> get_the_date( 'Y-m-d H:i:s', $attachment_id )
    );
    
    
    $new_postid = wp_insert_post( $args );

    See: https://developer.wordpress.org/reference/functions/wp_insert_post/

    Editing:

    See:

    • https://developer.wordpress.org/reference/functions/wp_update_post/
    • https://developer.wordpress.org/reference/functions/wp_set_object_terms/

    Deleting

    wp_delete_post( $post_id );

    See: https://developer.wordpress.org/reference/functions/wp_delete_post/