$postを使用して投稿の情報を取得します。
下記URLの本家サイトから引用させていただき、使いそうな項目だけ日本語をつけました。
引用元=https://codex.wordpress.org/Function_Reference/$post
$post
Contains data from the current post in The Loop.
Properties
- ID
(integer) The post ID. 投稿のID - post_author
(integer) The ID of the post author. 投稿者のID - post_date
(string) The post date using the server’s current timezone. 投稿日時
Format: yyyy-mm-dd hh:mm:ss
Example: 2011-05-19 13:51:21 (default Unix format ‘F j, Y’) - post_date_gmt
(string) Same as above, but in GMT. 投稿日時GMT - post_content
(string) The post content. 投稿内容 - post_title
(string) The post’s title. 投稿タイトル - post_excerpt
(string) The post’s excerpt, if one is set. 投稿の抜粋 - post_status
(string) See get_post_status for possible values. 投稿の状態 - comment_status
(string) See wp_get_comment_status for possible values. コメント投稿の状態 - ping_status
(string) Values: ‘open’ or ‘closed’. - post_password
(string) The post’s password. - post_name
(string) The post’s slug. 投稿のスラッグ - to_ping
(string) Addresses to be pinged. - pinged
(string) Addresses already pinged. - post_modified
(string) Date the post was last modified using server’s timezone. - post_modified_gmt
(string) Same as above in GMT. - post_content_filtered
- post_parent
(integer) ID of the post’s parent, if it has one. - guid
(string) A link to the post. This is not the permalink. To get the permalink use get_permalink. - menu_order
(integer) The value set in the ‘Order’ field for pages. - post_type
(string) The post type. - post_mime_type
(string) Mime Type (for attachments, etc). - comment_count
(integer) The number of approved comments. - ancestors
(array) An array of the post’s ancestors’ IDs (parent, parent’s parent, etc). [0] = parent, [1] = grandparent, etc. - filter
(string)
Usage
<?php global $post; echo $post->post_title; ?>