on page
page.php
Get category slug by ID
$category = get_category( $category_ID );
echo $category->slug;
Get category name by ID
$category = get_category( $category_ID );
echo $category->name;
Get category ID by slug
$idObj = get_category_by_slug( $cateslug );
$categoryID = $idObj->term_id;
Get tag name by ID
echo get_term_by('id' ,ここにタグID, 'post_tag')->name;
Get tag name by slug
$tag = get_term_by('slug', ここにタグスラッグ, 'post_tag');
echo $tag->name;
on category
category.php
Get category ID
$getcategory = get_category( get_query_var( 'cat' ) );
$cateid = $getcategory->cat_ID;
Get parent category ID
$cateid = get_query_var( 'cat' );
$child = get_category($cateid);
$parentID = $child->parent;
Get category name
echo get_queried_object()->name;
single_cat_title('' , true );
on tag
tag.php
Get tag id
$tag_id = get_query_var('tag_id');
Anywhere
Get post id by url
$postid = url_to_postid( $url );