Add WordPress Meta Box saved form input to WordPress RSS feed

I’m teaching myself how to build WordPress plugins. I found a great guide to creating a WordPress Meta Box and saving the form input from it.

https://themefoundation.com/wordpress-meta-boxes-guide/

I want to send the entered and saved form input from the Meta Box that is in the Post edit view of WordPress to the WordPress RSS in its own tag. So when the user publishes the Post the Meta Box form data saves and adds the saved input to the post WordPress RSS nested in its own tag.

This is the code that saves the form input:

function prfx_meta_save( $post_id ) {

// Checks save status
$is_autosave = wp_is_post_autosave( $post_id );
$is_revision = wp_is_post_revision( $post_id );
$is_valid_nonce = ( isset( $_POST[ ‘prfx_nonce’ ] ) && wp_verify_nonce( $_POST[ ‘prfx_nonce’ ], basename( __FILE__ ) ) ) ? ‘true’ : ‘false’;

// Exits script depending on save status
if ( $is_autosave || $is_revision || !$is_valid_nonce ) {
return;
}

// Checks for input and sanitizes/saves if needed
if( isset( $_POST[ ‘meta-text’ ] ) ) {
update_post_meta( $post_id, ‘meta-text’, sanitize_text_field( $_POST[ ‘meta-text’ ] ) );
}

}
add_action( ‘save_post’, ‘prfx_meta_save’ );

Read more here:: Add WordPress Meta Box saved form input to WordPress RSS feed

Leave a Reply

Your email address will not be published. Required fields are marked *