Inject HTML meta tag inside wordpress tag using add_shortcode

First thing, wp_head action hook does not accept any argument at all, so am not sure whether the $url variable will be passed.

To run the short code properly, you have to call do_shortcode():


add_action( 'wp_head', 'refresh_page' );

function refresh_page()
{
    echo do_shortcode( "[refresh url="http://stackoverflow.com"]" );
}


add_shortcode( 'refresh',  'refresh_shortcode' );

function refresh_shortcode( $atts ) {
    $atts = shortcode_atts( array(
        'url' => '',
    ), $atts, 'refresh' );

    $url = esc_url_raw( $atts['url'] );

    return '<meta http-equiv="refresh" content="' . $url . '">';
}