I want to echo PHP variable value on any page using shortcode in WordPress.
I have created:
function custom_shortcode() {
echo $unique;
}
add_shortcode( 'test', 'custom_shortcode' );
When I place shortcode [test] on any page, it returns nothing.
The $unique variable is to show the logged-in user's username in URL. For example: example.com/?username
The expected output on front-end need to be: example.com/?username