WordPress 現在の固定ページのスラッグを取得

/ WordPress / Comment[0]

attribute_escape()やget_page()は非推奨なのでget_page_uri()を使います。

<?php echo get_page_uri($post->ID); ?>

127.0.0.1/testという固定ページなら「test」
127.0.0.1/linux/ubuntuという固定ページなら「linux/ubuntu」が取れます。

関連記事

コメント

:
:
:
:
:
管理人のみ表示を許可