Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私はWordpressでいくつかのPHPをいじっています。すべての新しい投稿タイトルに、投稿名から取得した一意の h1 ID を付与しようとしています。
したがって、「第 1 章」という名前の投稿を投稿する場合、タイトルは次のようになります。
<h1 id="Chapter 1">Chapter 1</h1>
次のコードは魔法を行っていません
<h1 id="<?php the_title(); ?>"><?php the_title(); ?></h1>
これを行う正しい関数はthe_ID();
the_ID();
例えば。:
<h1 id="<?php the_ID(); ?>"><?php the_title(); ?></h1>
参照リンク: http://codex.wordpress.org/Function_Reference/the_ID