はじめに

WordPressのテーマやプラグイン作成において、よく利用する関数やグローバル変数などを個人的に整理したコンテンツです。 各関数やグローバル変数は、情報別(データの種類)と目的別(機能の種類)に分類しています。 なお、ほとんどの情報はソースコードを見ながら書き留めた内容であり、確認不足による誤りや更新の遅れによる不正確な内容を含んでいる可能性があります。あらかじめご了承ください。

最近投稿した記事
投稿にシーケンス図を入れたい(2025年1月28日 公開)

VSCodeに「Markdown PDF」という拡張機能をインストールし、シーケンス図をPDFファイルとしてエクスポートした際、中間ファイルとしてHTMLファイルが生成されていた。このHTMLファイルを見た際、この仕組みはWordPressのcodeブロックでも利用できるのではと思い挑戦した。

is_post_type_hierarchical(2024年12月4日 公開)
bool is_post_type_hierarchical( string $post_type )
投稿タイプが階層的か調べる。
get_user(2024年11月21日 公開)
WP_User|false get_user( int $user_id )
ユーザーIDのユーザー情報を取得する。
wp_img_tag_add_auto_sizes(2024年11月19日 公開)
string wp_img_tag_add_auto_sizes( string $image )
img要素のsizes属性にautoを追加する。
get_edit_comment_link(2024年11月18日 公開)
string|void get_edit_comment_link( [ int|WP_Comment $comment_id = 0 [ , string $context = 'display' ] ] )
コメント編集用のリンク(URL)を取得する。
has_translation(2024年11月15日 公開)
bool has_translation( string $singular [ , string $textdomain = 'default' [ , ?string $locale = null ] ] )
翻訳テキストが存在するか調べる。
wp_is_heic_image_mime_type(2024年11月15日 公開)
bool wp_is_heic_image_mime_type( string $mime_type )
MIMEタイプがHEIC/HEIF画像か調べる。
wp_get_wp_version(2024年11月15日 公開)
string wp_get_wp_version()
WordPressのバージョン番号を取得する。
wp_check_comment_data(2024年11月14日 公開)
int|string|WP_Error wp_check_comment_data( array $comment_data )
コメントデータが内部チェック済みまたは未許可でないか調べる。