the_author() – выводит имя автора «Отображать как» для текущей записи

Функция the_author() не имеет параметров и должна использоваться непосредственно в цикле WordPress. Смотрите мой видеоурок про циклы.

the_author( $deprecated = '', $deprecated_echo = true )

Ранее функции get_the_author() не существовала, и the_author() была основной функцией, которая могла возвращать или выводить имя автора в зависимости от переданных в неё параметров. Теперь эти параметры являются устаревшими, но остались в функции для обеспечения обратной совместимости.

Сегодня используйте функцию the_author() только для вывода имени (display_name) автора поста. Под именем подразумевается то, что настроено пользователем в него в профиле в опции «Отображать как»:

display name пользователя WordPress

Пример

<p>Этот пост опубликовал(а): <?php the_author(); ?></p>
Кодекс WordPress: Пользователи, Цикл: add_user_meta(), author_can(), wp_login_form(), current_user_can(), email_exists(), get_avatar(), get_avatar_url(), get_children(), get_current_user_id(), get_delete_post_link(), get_edit_post_link(), get_extended(), get_next_posts_link(), get_permalink(), get_post_type(), get_posts(), get_previous_posts_link(), get_queried_object_id(), get_query_var(), get_search_query(), get_the_author(), get_the_author_meta(), get_the_author_posts(), get_the_content(), get_the_date(), get_the_excerpt(), get_the_ID(), get_the_modified_author(), get_the_time(), get_the_title(), get_user_by(), get_user_meta(), has_excerpt(), has_post_thumbnail(), have_posts(), is_user_logged_in(), next_posts_link(), paginate_links(), post_class(), previous_posts_link(), query_posts(), setup_postdata(), the_author(), the_content(), the_date(), the_excerpt(), the_ID(), the_permalink(), the_post(), the_search_query(), the_time(), the_title(), the_title_attribute(), update_user_meta(), username_exists(), wp(), wp_dropdown_users(), wp_get_current_user(), wp_insert_user(), wp_new_user_notification(), WP_Query, wp_reset_postdata(), wp_reset_query(), wp_set_auth_cookie(), wp_set_password(), wp_signon(), WP_User_Query

Источник: Блог Миши Рудрастых

Миша Рудрастых

Путешествует по миру и рассказывает всем о WordPress лично, у себя в блогах и на курсах в Санкт-Петербурге. Умеет просто объяснять сложные вещи, делает это красиво. Организовывает неплохие WordCamp's, но совсем не умеет слушать чужие доклады.

Добавить комментарий