I have a simple shortcode to show post_type slug when I needed.
when using shortcode in text widget:
-in "post_type single page" it's working
-But in same sidebar and same widget in "post_type archive page" returns nothing.
the strange thing is the same shortcode is working when using do_shortcode function even in the "post_type archive page" template but in text widget has no success.
function post_type_slug()
{
$string = get_post_type();
return $string;
}
add_shortcode('pts', 'post_type_slug');
unfortunately I have no success with get_post_type() but get_queried_object() helped.
I changed the code to:
and it's working in text widget now.