And last question resolved again. Here the code:
function createPostListSubCatWork() {
global $post;
$categories = wp_get_object_terms( $post->ID, 'category', [ 'parent' => 1, 'number' => 99 ] );
$categoryOutput = [];
if (!empty($categories)) {
array_push($categoryOutput, '<ul class="_Default">');
foreach($categories as $category) {
array_push($categoryOutput, '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </br> ');
}
array_push($categoryOutput, '</ul>');
}
return implode('', $categoryOutput);
}
add_shortcode('work_cats_pg', 'createPostListSubCatWork');
- List categories for the current post: [work_cats_pg]
- The categories should be children of category 1.
- No more than 99 positions should be displayed.
Source which kinde resolved it for me: https://wordpress.stackexchange.com/questions/330128/display-a-list-of-subcategories-from-specific-category-a-post-belongs-to
Best regards,
Amadezs