在使用PHP发布帖子时如何禁用wordpress的插件?

I load wordpress with my php code like this to do actions:

define( 'WP_USE_THEMES', false ); // Don't load theme support functionality
require( './wp-load.php' );

How could I also disable plugins temporarily when I want to add posts, etc? This would be to use less server resources...

I don't believe there's actually a good way to do this. The best way is probably to run your function before plugins are loaded. Otherwise you're looking at programatically renaming the /plugins folder or WP_PLUGIN_[DIR/URL] constants which just screams "error prone"

Effectively you can hook into the first action hook available, which is muplugins_loaded: Source. Especially if you have no mu-plugins to be run, it should be run almost instantaneously:

add_action( 'muplugins_loaded', 'run_before_plugins_load' );
function run_before_plugins_load(){
    if( condition == met ){
        // Insert your post here
        if( $post_id = wp_insert_post( $my_post ) ){
           exit(); // Post inserted, stop processing anything.
        } else {
           wp_die( 'Post not inserted' );
        }
    }
}

From there you'll have inserted a post and stopped any further propagation. Of course, you can replace exit and wp_die with whatever you want - it's just the fastest way I can see to run a WP function without actually loading plugins.