LoginSignup
14

More than 5 years have passed since last update.

posted at

updated at

【WordPress】ページスラッグからパーマリンクを取得する

php
<?php
$page = get_page_by_path( 'スラッグ' );
$permalink = get_permalink( $page->ID );
?>
<a href="<?php echo $permalink; ?>">

コレでできた。

php
<a href="<?php echo get_permalink( get_page_by_path( 'スラッグ' )->ID ); ?>">

一行でもできる。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
14