revision id is one number behind – publish_post

See this- function check_values( $post_ID, $post ) { $revisions = wp_get_post_revisions( $post_ID ); $revision_ids = []; foreach ( $revisions as $revision ) { $revision_ids[] = $revision->ID; } // $revision_ids; // holds all revision ids // $revision_ids[0]; // latest revision // $revision_ids[1]; //revision just before the latest one } add_action( ‘publish_post’, ‘check_values’, 10, 2 );

Fatal error: Call to undefined function add_action() – an untouched problem

get_stylesheet_directory_uri() returns an URL. The requested file is called like any other publicly available resource: without the context of the include statement. This is like opening the PHP file in a browser directly. There is no WordPress context, and the functions add_action() or add_filter() are not defined. Use get_template_directory() in parent themes and get_stylesheet_directory() in … Read more

Post date on Custom field

There is a hook called save_posts so you need to hook a function into that post like add_action(‘save_posts’,’store_date’); function store_date(){ if(get_post_type()==’post’){ $month=get_the_date(‘M’); $year=get_the_date(‘Y’); update_post_meta(get_the_ID(),’month-field’,$month); update_post_meta(get_The_ID(),’year-field’,$year); } } This should be all you need Here are additonal links to save_posts and update_post_meta

how to create php file and load it in wordpress post?

It is not normal practice in WP development to include executable PHP in content. Most typically this would be implemented with a shortcode which provides safe element to put into content, which renders a more complicated output required. Not sure about download.php part, I would guess that might be better off incorporated into WP runtime … Read more