如果您在循环之外,则可以使用通过post id获取它们,您可以使用以下代码片段:
作者姓名的短代码:
function author_name_shortcode(){
    global $post;
    $post_id = $post->ID;
    $author = get_the_author($post_id);
    return $author;
}
add_shortcode(\'post_author\',\'author_name_shortcode\');
 类别名称的快捷码:
function category_name_shortcode(){
    global $post;
    $post_id = $post->ID;
    $catName = "";
    foreach((get_the_category($post_id)) as $category){
        $catName .= $category->name . " ,";
    }
    return $catName;
}
add_shortcode(\'post_category\',\'category_name_shortcode\');