WordPressのテーマやプラグイン作成において、よく利用する関数やグローバル変数などを個人的に整理したコンテンツです。 各関数やグローバル変数は、情報別(データの種類)と目的別(機能の種類)に分類しています。 なお、ほとんどの情報はソースコードを見ながら書き留めた内容であり、確認不足による誤りや更新の遅れによる不正確な内容を含んでいる可能性があります。あらかじめご了承ください。
WordPressのテーマやプラグイン作成において、よく利用する関数やグローバル変数などを個人的に整理したコンテンツです。 各関数やグローバル変数は、情報別(データの種類)と目的別(機能の種類)に分類しています。 なお、ほとんどの情報はソースコードを見ながら書き留めた内容であり、確認不足による誤りや更新の遅れによる不正確な内容を含んでいる可能性があります。あらかじめご了承ください。
WordPress にはテキスト整形のための API が用意されていて、プラグインを作るときなどにはあらかじめ知っておくと重宝します。とはいえ関数が多くて把握しきれないので、自分用のメモとしてまとめてみようと思いました。 以下、WordPress 2.1.3 の wp-includes/formatting.php で定義される関数の一覧です。気が向いたときに注釈を書き足すつもりです。 wptexturize($text) HTML のタグを除いた本文の整形を行う。グローバル変数 $wp_cockneyreplace を参照するのでこの変数で独自の置換パターンを定義することも可能。 clean_pre($text) <br /> タグの削除、<p> タグの \n への変換を行う。<pre> タグの内容を整形するために wpautop() の中で使われている。 wpautop($pee, $
WordPressのカテゴリーアーカイブページでパンくずリストを表示する方法です。 1.概要 このエントリーでは次のように、パンくずリストの先頭にホームへのリンクを表示し、その右側にカテゴリー名をセパレータ「>」つきで表示します。 2.カスタマイズ 青色部分のコードを、アーカイブテンプレートのカテゴリー判定部分に記述します。 <?php if (is_category()) { ?> <div class="crumbs"><a href="<?php echo get_option( 'home' ); ?>/">Home</a> > <?php $cat = get_queried_object(); $breadcrumbs = get_category_parents( $cat, true, ' > ' ); echo preg_replace( '/(.*) >
[2013/07/25 追記] get_posts で検索してこの記事にアクセスされる方が多いのですが、この記事はquery_postsとget_postsをソースコードで比較したものですので、使い方を知りたい方は「WordPressでページ送りが動かないのはどう考えてもquery_postsが悪い!【pre_get_postsまとめ】」も合わせてご覧ください。 query_posts と get_posts。どちらもWordPressから投稿のデータを取得するのに使えるので、特に使い分けを意識していない方も多いのではないかと思います。自分自身もはっきり結論がでているわけではないのですが、今回はこの違いについて考えてみます。 ※ WordPressについての立ち入った内容なので、予めお断りしておきます wp-includes/query.php に書かれています。 function &am
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く