How can i get the Page-ID in a WordPress Shortcode in Visual Composer Header

Solution:1

I found out how to do this by myself. If anyone is in the same Situation, here is the solution to this. There is a function called get_page_by_path() in wordpress which searches for your page based on the permalink. I’m using this code in the Shortcode, which is included in the Visual Composer Header-Element and displayed in a subpage, to get the Page-ID from the site which includes the header and not the Header iteself (which is a posttype in wordpress too).

$pageId = get_page_by_path($_SERVER["REQUEST_URI"])->ID;

Solution:2

get current page id or post id on the frontend

$page_id = get_the_ID();
OR
$post_id = get_the_ID();

get term id on archive page on frontend

$category = get_queried_object();
$term_id = $category->term_id;