Solution:
You can use the wordpress function ‘is_singular()’ or ‘is_page(“Post ID|title|slug”)’ to check if you are in single post page. E.g
if(is_singular() && is_page("post-title")) {
// ...
}
Remember to always return from your shortcode function callback. So your solution should be:
if(is_singular() && is_page("title")) {
function test_query($atts, $content = null, $tag){
function update_post_b( $post_id, $post, $update ){
if .....
# perform actions based on $atts
$posts = get_posts(array( ....
# Always return :)
return $post;
}
add_action( 'save_post_infosubmission', 'update_post_b', 10, 3 );
}
# Shortcodes are hooked into the 'init' action
add_action('init', add_shortcode( 'test-query', 'test_query' ));
}
To know more about the parameters in the ‘test_query’, what they do and how to handle them, check the wp plugin handbook doc on shortcodes https://developer.wordpress.org/plugins/shortcodes/shortcodes-with-parameters/
Happy debugging 🙂