0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

wordpress サイトのURLを取得

Posted at

サイト名にトップページのリンクを付ける

<h1>
  <a href="<?php echo esc_url( home_url( '/' ) ); ?>">
    <?php bloginfo( 'name' ); ?>
  </a>
</h1>

トップページ以外のサイトURLを出力

<?php $about_url = home_url( '/任意のページ/' ); ?>

singleページのURL出力

<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>

※この関数はwordpressループの中でしか使用できない

singleページURLを文字列として取得
get_permalink()

記事IDが1番目の投稿URLを返す
<?php $permalink = get_permalink( 1 ); ?>

※存在しない場合、falseが返ってくる
0
0
0

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
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?