Tell us what you are trying to do?I am trying to execute a custom shortcode. I wrote the shortcode as:
add_shortcode( 'rvr-update-author', 'rvr_update_author_function' );
function rvr_update_author_function( $atts ) {
$a = shortcode_atts( array('userid' => '3'), $atts );
$userid = $a['userid'];
get_user_data(userid);
$user_email = $user_info->user_email;
$loop = new WP_Query( array( 'post_type' => 'rally', 'posts_per_page' => -1) );
while ( $loop->have_posts() ) : $loop->the_post();
function_alert ("Rally Email: ".get_post_meta(get_the_ID(),'wpcf-rallyemail',true));
if(get_post_meta(get_the_ID(),'wpcf-rallyemail',true)== $user_email )
{
$arg = array(
'ID' => get_the_ID(),
'post_author' => $userid,
);
wp_update_post( $arg );
}
endwhile;
wp_reset_postdata();
}
1. I placed this code in the functions.php file.
2. I added a new page
3. I typed [rvr-update-author] in a text paragraph
4. I clicked - Publish
Wordpress indicates that it failed to publish.
Is there any documentation that you are following?Yes: https://toolset.com/documentation/adding-custom-code/how-to-create-a-custom-shortcode/
Is there a similar example that we can see?
What is the link to your site?rvrally.net
It turns out to be a block editor problem.