Creating a shortcode is fairly simple, it only needs a shortcode name and maybe some arguments. Here is a simple one for you:
add_shortcode('my-shortcode','my_shortcode_function');
function my_shortcode_function(){
return '<div id="search-nacionalidad"><p class="'. get_field('nacionalidad').' noselect" title="'.get_field('nacionalidad').'" alt="'. get_field('nacionalidad').'">'.get_field('nacionalidad').'</p></div>';
}
Now, using [my-shortcode]
exactly does what your code does. However I'm not sure how do you use this, whether in a loop or not. If you need to pass the post's ID too, you need to use attributes. Take a look at this:
add_shortcode('my-shortcode','my_shortcode_function');
function my_shortcode_function($atts){
$atts = shortcode_atts( array(
'id' => '0',
), $atts, 'my-shortcode' );
$id = $atts['id'];
return '<div id="search-nacionalidad"><p class="'. get_the_field('nacionalidad',$id).' noselect" title="'.get_the_field('nacionalidad',$id).'" alt="'. get_the_field('nacionalidad',$id).'">'.get_the_field('nacionalidad',$id).'</p></div>';
}
Now if you use [my-shortcode id="123"]
it will execute the code for the post that has an ID of 123. If no ID is provided, a default ID of 0 will be used instead.