워드프레스에서 글 제목(Post title), 발행 날짜(Publish date), 작성자(Author) 등의 정보를 호출하는 함수 정리
글 제목:
get_the_title( int|WP_Post $post )
예시:
echo get_the_title();
참고: https://developer.wordpress.org/reference/functions/get_the_title/
작성 날짜:
get_the_date( string $d = '', int|WP_Post $post = null )
예시:
“Monday January 11, 2017” 형식
$post_date = get_the_date( 'l F j, Y' ); echo $post_date;
“Wed Jan 9” 형식
$post_date = get_the_date( 'D M j' ); echo $post_date;
날짜 형식은 다음 글을 참고해보세요.
참고: https://developer.wordpress.org/reference/functions/get_the_date/
작성자:
get_the_author_meta( string $field = '', int $user_id = false )
예시:
<p>Email the author: <a href="mailto:<?php echo get_the_author_meta( 'user_email', 25 ); ?>"><?php
the_author_meta( 'display_name', 25 ); ?></a></p>
참고: https://developer.wordpress.org/reference/functions/get_the_author_meta/