<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>FAQ &#187; coding</title>
	<atom:link href="http://tenman.info/labo/manual/category/coding/feed/" rel="self" type="application/rss+xml" />
	<link>http://tenman.info/labo/manual</link>
	<description>Just another 仙台入門new weblog</description>
	<lastBuildDate>Fri, 20 Aug 2010 09:14:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>逆引き　　テンプレートコーディング</title>
		<link>http://tenman.info/labo/manual/2009/06/05/%e9%80%86%e5%bc%95%e3%81%8d%e3%80%80%e3%80%80%e3%83%86%e3%83%b3%e3%83%97%e3%83%ac%e3%83%bc%e3%83%88%e3%82%b3%e3%83%bc%e3%83%87%e3%82%a3%e3%83%b3%e3%82%b0/</link>
		<comments>http://tenman.info/labo/manual/2009/06/05/%e9%80%86%e5%bc%95%e3%81%8d%e3%80%80%e3%80%80%e3%83%86%e3%83%b3%e3%83%97%e3%83%ac%e3%83%bc%e3%83%88%e3%82%b3%e3%83%bc%e3%83%87%e3%82%a3%e3%83%b3%e3%82%b0/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 04:51:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[管理者]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://tenman.info/labo/manual/?p=688</guid>
		<description><![CDATA[head lineブログ名メインページへのURLサブタイトルメタタイプの入力ここの部分&#60;?php bloginfo('html_type');?&#62;文字コード&#60;?php bloginfo('charset [...]]]></description>
			<content:encoded><![CDATA[<a name="TOP" id="TOP">head line</a><ul><li><a href="#h2h21">ブログ名</a></li><li><a href="#h2h22">メインページへのURL</a></li><li><a href="#h2h23">サブタイトル</a></li><li><a href="#h2h24">メタタイプの入力</a></li><li><a href="#h2h25">ここの部分&lt;?php bloginfo('html_type');?&gt;</a></li><li><a href="#h2h26">文字コード&lt;?php bloginfo('charset');?&gt;</a></li><li><a href="#h2h27">スタイルシートの適応</a></li><li><a href="#h2h28">バージョン情報</a></li><li><a href="#h2h29">フィールドファイルのアドレス（RSSとATOM）</a></li><li><a href="#h2h210">前後ページへリンクする</a></li><li><a href="#h2h211">最近の記事のメニューリストを作る</a></li><li><a href="#h2h212">カテゴリーメニューリスト</a></li><li><a href="#h2h213">月別のアーカイブメニュー</a></li><li><a href="#h2h214">ファッションスタイル</a></li><li><a href="#h2h215">クエリースタイル</a></li><li><a href="#h2h216">管理画面へのログイン</a></li><li><a href="#h2h217">ユーザ登録、登録画面へのリンク</a></li><li><a href="#h2h218">記事タイトルのループ表示</a></li><li><a href="#h2h219">記事タイトルのループ表示（beforeとafterの記載例）</a></li><li><a href="#h2h220">記事タイトルのシングル表示</a></li><li><a href="#h2h221">記事の内容のループ表示</a></li><li><a href="#h2h222">記事の内容のループ表示（文字だけ）</a></li><li><a href="#h2h223">カスタムフィールドのエリア、キーワードを表示</a></li><li><a href="#h2h224">記事のID（カウント）を表示</a></li><li><a href="#h2h225">記事のURLを表示する</a></li><li><a href="#h2h226">複数に分裂した記事番号へのURLの表示</a></li><li><a href="#h2h227">複数に分裂したページに前後リンクを表示させる</a></li><li><a href="#h2h228">記事の投稿日を表示する</a></li><li><a href="#h2h229">カテゴリー名を表示する</a></li><li><a href="#h2h230">カテゴリーのパンぐずリストを表示</a></li><li><a href="#h2h231">アーカイブメニューを表示する</a></li><li><a href="#h2h232">カレンダーを表示する</a></li><li><a href="#h2h233">パーツを読み込む</a></li><li><a href="#h2h234">コンディショナルタグ</a><ul><li><a href="#h3h31">ダイナミックハイライトメニュー</a></li><li><a href="#h3h32">ダイナミックタイトルタグ</a></li><li><a href="#h3h33">ダイナミックコンテンツ</a></li><li><a href="#h3h34">ハイライトする記事を目立たせる</a></li><li><a href="#h3h35">1つのテンプレートをユニークにする</a></li><li><a href="#h3h36">カテゴリテンプレートをユニークにする</a></li></ul></li><li><a href="#h2h235">クエリーポスト</a><ul><li><a href="#h3h37">最新記事を表示する</a></li><li><a href="#h3h38">特定の記事を表示する</a></li><li><a href="#h3h39">特定のカテゴリから除外する</a></li></ul></li><li><a href="#h2h236">カスタムフィールド</a></li><li><a href="#h2h237">リストページ</a><ul><li><a href="#h3h310">サイトマップ</a></li><li><a href="#h3h311">ダイナミックサブページメニュー</a></li></ul></li><li><a href="#h2h238">ページテンプレート</a></li><li><a href="#h2h239">/</a></li><li><a href="#h2h240">WordPress各種設定</a><ul><li><a href="#h3h312">トップページをカスタムする</a></li><li><a href="#h3h313">パーマリンク</a></li></ul></li><li><a href="#h2h241">カテゴリ接頭語</a>
</li>
</ul>

</ul>
<h2 id="h2h21">ブログ名</h2>

<p>&lt;?php bloginfo('name');?&gt;

</p>

<h2 id="h2h22">メインページへのURL</h2>

<p>&lt;?php bloginfo('url');?&gt;

</p>

<h2 id="h2h23">サブタイトル</h2>

<p>&lt;?php bloginfo('description');?&gt;

</p>

<h2 id="h2h24">メタタイプの入力</h2>

<p>&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;ここの部分; charset=文字コード&quot; /&gt;

</p>

<p>例）<br />
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;&lt;?php bloginfo('html_type');?&gt;; charset=&lt;?php bloginfo('charset');?&gt;&quot; /&gt;

</p>

<h2 id="h2h25">ここの部分&lt;?php bloginfo('html_type');?&gt;</h2>

<h2 id="h2h26">文字コード&lt;?php bloginfo('charset');?&gt;</h2>

<h2 id="h2h27">スタイルシートの適応</h2>

<p>&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;&lt;?php bloginfo('stylesheet_url'); ?&gt;&quot; /&gt;

</p>

<h2 id="h2h28">バージョン情報</h2>

<p>&lt;meta name=&quot;generator&quot; content=&quot;WordPressここの部分&quot;/&gt;

</p>

<p>例）<br />
&lt;meta name=&quot;generator&quot; content=&quot;WordPress&lt;?php bloginfo('charset');?&gt;&quot;/&gt;

</p>

<p>&lt;?php bloginfo('charset');?&gt;

</p>

<h2 id="h2h29">フィールドファイルのアドレス（RSSとATOM）</h2>

<p>&lt;link rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot; title=&quot;&lt;?php bloginfo('name');?>(RSS2.0)&quot; href=&quot;&lt;?php bloginfo(&quot;rss2_url&quot;); ?&gt;&quot; /&gt;

</p>

<p>&lt;link rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot; title=&quot;&lt;?php bloginfo('name');?>(RSS2.0)&quot; href=&quot;&lt;?php bloginfo(&quot;atom_url&quot;); ?&gt;&quot; /&gt;

</p>

<p>記事タイトルをリストアップ

</p>

<p>&lt;?php if(have_posts() ): while(have_posts() ): the_post(); ?&gt;

</p>

<p>&lt;h2&gt;&lt;?php the_title(); ?&gt;&lt;/h2&gt;　//記事タイトル

</p>

<p>&lt;?php the_content(); ?&gt;　//記事タイトル

</p>

<p>&lt;?php endwhile; endif; ?&gt;

</p>

<h2 id="h2h210">前後ページへリンクする</h2>

<p>&lt;?php posts_nav_link(' |','&laquo;前のページ','次のページ &raquo;'); ?&gt;

</p>

<p>表示設定で設定した数値が超えたときに表示されます。

</p>

<h2 id="h2h211">最近の記事のメニューリストを作る</h2>

<p>&lt;?php wp_get_archives('type=postbypost&amp;limit=10'); ?&gt;

</p>

<h2 id="h2h212">カテゴリーメニューリスト</h2>

<p>&lt;?php list_cats(0,'name')?&gt;

</p>

<h2 id="h2h213">月別のアーカイブメニュー</h2>

<p>&lt;?php wp_get_archives('type=monthly'); ?&gt;

</p>

<p>テンプレートタグ種類

</p>

<h2 id="h2h214">ファッションスタイル</h2>

<p>1. パラメータの記述（パラメータ値を指定する。このとき、文字列（'type','format','before','after'）・数値（'limit',）パラメータ（show_post_count）は「''」で囲む。またブーリアンの場合は「''」で囲まない。

</p>

<p>例）&lt;?php get_archives('type','limit','format','before','after',show_post_count); ?&gt;

</p>

<p>注意）指定順序を変えないこと、省略もしないこと

</p>

<p>デフォルトの指定）&lt;?php get_archives();?&gt;、またはパラメータのデフォルトの指定は&lt;?php　get_archives('','','','before','after',show_post_count); ?&gt;

</p>

<h2 id="h2h215">クエリースタイル</h2>

<p>1. クエリーの記述（パラメータ名と値）

</p>

<p>例）&lt;?php wp_get_archives('type=xx &amp; limit=xx &amp; format=xx &amp; before=xx &amp; after=xx &amp; show_post_count=xx'); ?&gt;

</p>

<p>テンプレートの分類

</p>

<p>一般

</p>

<p>記事

</p>

<p>日付

</p>

<p>カテゴリー

</p>

<p>リンク

</p>

<p>コピーライト

</p>

<p>コメント

</p>

<p>その他

</p>

<p>パラメータの一覧

</p>

<h2 id="h2h216">管理画面へのログイン</h2>

<p>&lt;?php wp_loginout(); ?&gt;

</p>

<h2 id="h2h217">ユーザ登録、登録画面へのリンク</h2>

<p>&lt;?php wp_register();?&gt;

</p>

<h2 id="h2h218">記事タイトルのループ表示</h2>

<p>&lt;?php if(have_posts() ):while(have_posts() ): the_post(); ?&gt;

</p>

<p>&lt;p&gt;&lt;?php the_title(); ?&gt;&lt;/p&gt;

</p>

<p>&lt;?php endwhile; endif; ?&gt;

</p>

<h2 id="h2h219">記事タイトルのループ表示（beforeとafterの記載例）</h2>

<p>&lt;?php if(have_posts() ):while(have_posts() ): the_post(); ?&gt;

</p>

<p>&lt;?php the_title('&lt;p&gt;','&lt;/p&gt;'); ?&gt; //このように記載すると上記と同じようになる。

</p>

<p>&lt;?php endwhile; endif; ?&gt;

</p>

<h2 id="h2h220">記事タイトルのシングル表示</h2>

<p>&lt;?php single_post_title(); ?&gt;

</p>

<h2 id="h2h221">記事の内容のループ表示</h2>

<p>&lt;?php if(have_posts() ):while(have_posts() ): the_post(); ?&gt;

</p>

<p>&lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;

</p>

<p>&lt;?php the_content(); ?&gt;

</p>

<p>&lt;?php endwhile; endif; ?&gt;

</p>

<h2 id="h2h222">記事の内容のループ表示（文字だけ）</h2>

<p>&lt;?php if(have_posts() ):while(have_posts() ): the_post(); ?&gt;

</p>

<p>&lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;

</p>

<p>&lt;?php the_excerpt(); ?&gt; //RSSの場合はthe_excerpt_rss();を使用する。

</p>

<p>&lt;?php endwhile; endif; ?&gt;

</p>

<h2 id="h2h223">カスタムフィールドのエリア、キーワードを表示</h2>

<p>&lt;?php if(have_posts() ):while(have_posts() ): the_post(); ?&gt;

</p>

<p>&lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;

</p>

<p>&lt;?php the_meta(); ?&gt;

</p>

<p>&lt;?php endwhile; endif; ?&gt;

</p>

<h2 id="h2h224">記事のID（カウント）を表示</h2>

<p>&lt;?php if(have_posts() ):while(have_posts() ): the_post(); ?&gt;

</p>

<p>&lt;h1&gt;&lt;?php the_ID(); ?&gt;&lt;/h1&gt;

</p>

<p>&lt;?php edit_post_link(); ?&gt;

</p>

<p>&lt;?php endwhile; endif; ?&gt;

</p>

<h2 id="h2h225">記事のURLを表示する</h2>

<p>&lt;?php if(have_posts() ):while(have_posts() ): the_post(); ?&gt;

</p>

<p>&lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;

</p>

<p>&lt;?php the_parmalink(); ?&gt;　//RSSの場合は&lt;?php parmalink_single_rss(); ?&gt;　//PHPの記述の場合&lt;?php echo get_parmalink(10); ?&gt;

</p>

<p>&lt;?php endwhile; endif; ?&gt;）

</p>

<h2 id="h2h226">複数に分裂した記事番号へのURLの表示</h2>

<p>&lt;?php if(have_posts() ):while(have_posts() ): the_post(); ?&gt;

</p>

<p>&lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;

</p>

<p>&lt;?php the_content(); ?&gt;

</p>

<p>&lt;p&gt;&lt;?php link_page(); /&gt;&lt;/p&gt;

</p>

<p>&lt;?php endwhile; endif; ?&gt;）

</p>

<h2 id="h2h227">複数に分裂したページに前後リンクを表示させる</h2>

<p>&lt;?php if(have_posts() ):while(have_posts() ): the_post(); ?&gt;

</p>

<p>&lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;

</p>

<p>&lt;?php the_content(); ?&gt;

</p>

<p>&lt;?php endwhile; endif; ?&gt;

</p>

<p>&lt;p&gt;&lt;?php posts_nav_link(); ?&gt;&lt;/p&gt;

</p>

<p>&lt;p&gt;&lt;?php previous_posts_link(); ?&gt;&lt;/p&gt;

</p>

<p>&lt;p&gt;&lt;?php next_posts_link(); ?&gt;&lt;/p&gt;

</p>

<h2 id="h2h228">記事の投稿日を表示する</h2>

<p>&lt;?php if(have_posts() ):while(have_posts() ): the_post(); ?&gt;

</p>

<p>&lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;

</p>

<p>&lt;?php the_date(); ?&gt; &lt;?php the_time(); ?&gt;

</p>

<p>&lt;?php endwhile; endif; ?&gt;

</p>

<h2 id="h2h229">カテゴリー名を表示する</h2>

<p>&lt;?php if(have_posts() ):while(have_posts() ): the_post(); ?&gt;

</p>

<p>&lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;

</p>

<p>&lt;?php the_category(); ?&gt; //ドロップダウンで表示させたい場合は&lt;?php dropdown_cats(); ?&gt;

</p>

<p>&lt;?php endwhile; endif; ?&gt;

</p>

<h2 id="h2h230">カテゴリーのパンぐずリストを表示</h2>

<p>&lt;?php echo get_category_parents($cat); ?&gt;

</p>

<h2 id="h2h231">アーカイブメニューを表示する</h2>

<p>&lt;?php get_archives(); ?&gt;

</p>

<p>&lt;?php get_archives('type=postbypost&amp;limit=5',); ?&gt;

</p>

<h2 id="h2h232">カレンダーを表示する</h2>

<p>&lt;?php get_calendar(); ?&gt;

</p>

<h2 id="h2h233">パーツを読み込む</h2>

<p>&lt;?php get_header(); ?&gt; //ヘッダーを読み込む

</p>

<p>&lt;?php get_footer(); ?&gt; //フッダーを読み込む

</p>

<p>&lt;?php get_sidebar(); ?&gt; //サイドを読み込む

</p>

<p>&lt;?php get_comments_template(); ?&gt; //コメントテンプレートを読み込む

</p>

<h2 id="h2h234">コンディショナルタグ</h2>

<p>コンディショナルタグは、どのコンテンツをいくつ表示するかをコントロールすることができる。

</p>

<h3 id="h3h31">ダイナミックハイライトメニュー</h3>

<p>Home、Category、Archive、Search、Singleのどれかのページにいるとすると、箇条書き（ナビゲーション）のはじめの項目のliタグに、class=&quot;current&quot;を追加する。

</p>

<p>例）&quot;about&quot;という名前のページにいるときに、class=&quot;current&quot;を追加する。

</p>

<p>&lt;ul id=&quot;nav&quot;&gt;<br />
&lt;li&lt;?php if ( is_home() | | is_category() | | is_archive() | | is_search() | | is_single() | | is_date() ) { echo ' class=&quot;current&quot;'; } ?&gt;&gt;&lt;a href=&quot;#&quot;&gt;Gallery&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&lt;?php if ( is_page('about') ) { echo ' class=&quot;current&quot;'; } ?&gt;&gt;&lt;a href=&quot;#&quot;&gt;About&lt;/a&gt;&lt;/li&gt;<br />
&lt;li&lt;?php if ( is_page('submit') ) { echo ' class=&quot;current&quot;'; } ?&gt;&gt;&lt;a href=&quot;#&quot;&gt;Submit&lt;/a&gt;&lt;/li&gt;<br />
&lt;/ul&gt;<br />

</p>

<h3 id="h3h32">ダイナミックタイトルタグ</h3>

<p>動的にtitleタグをheader.phpに加える

</p>

<p>&lt;title&gt;<br />
&lt;?phpif (is_home()) {<br />
echo bloginfo('name');<br />
} elseif (is_404()) {<br />
echo '404 Not Found';<br />
} elseif (is_category()) {<br />
echo 'Category:'; wp_title('');<br />
} elseif (is_search()) {<br />
echo 'Search Results';<br />
} elseif ( is_day() | | is_month() | | is_year() ) {<br />
echo 'Archives:'; wp_title('');<br />
} else {echo wp_title('');<br />
}<br />
?&gt;<br />
&lt;/title&gt;

</p>

<h3 id="h3h33">ダイナミックコンテンツ</h3>

<p>トップページのみに表示されるファイルを指定

</p>

<p>&lt;?php if ( is_home() ) { include ('file.php'); } ?&gt;<br />

</p>

<h3 id="h3h34">ハイライトする記事を目立たせる</h3>

<p>CSSクラスを追加

</p>

<p>&lt;?php if ( in_category('2') ) { echo ('class=&quot;feature&quot;'); } ?&gt;

</p>

<h3 id="h3h35">1つのテンプレートをユニークにする</h3>

<p>あるカテゴリで個々の記事を表示するために、1つの違うテンプレートを使いたいとする。<br />
記事がどのカテゴリに属しているかをin_categoryでチェックし、それからテンプレートを選択すればよい。

</p>

<p>デフォルトのsingle.phpには、以下のコードを入力する。記事がカテゴリ1に属していればsingle1.phpというテンプレートを使い、一方カテゴリ2であればsingle2.php、ほかのものならばsingle_other.phpを適用する、というコードになっている。

</p>

<p>&lt;?php<br />

</p>

$post= $wp_query- &gt;post;
<p>if ( in_category('1') ) {<br />
include(TEMPLATEPATH . '/single1.php');<br />
} elseif ( in_category('2') ) {<br />
include(TEMPLATEPATH . '/single2.php');<br />
} else {<br />
include(TEMPLATEPATH . '/single_other.php');<br />
}<br />
? &gt;

</p>

<h3 id="h3h36">カテゴリテンプレートをユニークにする</h3>

<p>異なるカテゴリテンプレートを使って、特定のカテゴリを表示したいとしよう。これは単純にカテゴリテンプレートをcategory-2.phpとして保存すればよい。（注意：&quot;-&quot;とカテゴリID番号をファイル名にする）すると、category-2.phpはカテゴリ2を表示した際に使われ、category-3.phpはカテゴリ3のときに使われる、など。

</p>

<p>（訳者注：上記と絡ませて使うと便利。コンディショナルタグで表示ページを指定し、カテゴリごとにページデザインを変える、など）

</p>

<p>1つ目の記事のあとにGoogle Adsenseを表示する

</p>

<p>多くの人が僕に質問する。「どうやって、1つ目の記事のあとにGoogle Adsenseを表示しているんだい？」これはすごく単純。ループ内に変数($loopcounter)を加えればよいだけだ。

</p>

<p>もし、$loopcounterが1以下、または等しいのであれば、そのときはgoogle-ad.phpを組み入れる。

</p>

<p>&lt;?php if (have_posts()) : ?&gt;&lt;?php while (have_posts()) : the_post(); $loopcounter++; ?&gt;<br />
// the loop stuffs<br />
&lt;?php if ($loopcounter &lt;= 1) { include (TEMPLATEPATH . '/ad.php'); } ?&gt;<br />
&lt;?php endwhile; ?&gt;<br />
&lt;?php else : ?&gt;<br />
&lt;?php endif; ?&gt;<br />

</p>

<h2 id="h2h235">クエリーポスト</h2>

<p>ループ内にいくつの記事を表示するのかを制御する

</p>

<p>どのコンテンツが、どこに、どうやって表示されるのかを制御させられるのがクエリーポスト

</p>

<p>特定のカテゴリにクエリーを要求することもできるし、除外することもできる。

</p>

<p>最新記事の一覧を表示したもの、特定の記事を表示するもの、またどうやって特定のカテゴリから除外するのかについて、クエリーポストを使った例を示してみよう。

</p>

<h3 id="h3h37">最新記事を表示する</h3>

<p>以下のコードが最新5件を一覧に表示するものだ。

</p>

<p>&lt;?php query_posts('showposts=5'); ?&gt;<br />
&lt;ul&gt;<br />
&lt;?php while (have_posts()) : the_post(); ?&gt;<br />
&lt;li&gt;&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/li&gt;<br />
&lt;?php endwhile;?&gt;<br />
&lt;/ul&gt;

</p>

<h3 id="h3h38">特定の記事を表示する</h3>

<p>カテゴリ2は特別なカテゴリとする。このカテゴリから5件をサイドバーに表示したい。そんなときは、こんなコードをsidebar.phpに入れればよい。

</p>

<p>&lt;?php query_posts('cat=2&amp;showposts=5'); ?&gt;<br />
&lt;ul&gt;<br />
&lt;?php while (have_posts()) : the_post(); ?&gt;<br />
&lt;li&gt;&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/li&gt;<br />
&lt;?php endwhile;?&gt;<br />
&lt;/ul&gt;

</p>

<h3 id="h3h39">特定のカテゴリから除外する</h3>

<p>特定のカテゴリを表示しない

</p>

<p>以下のコードはカテゴリ2の全ての記事を除外したものだ。（注意：ID番号の前にマイナス記号が入っている）

</p>

<p>&lt;?php query_posts('cat=-2'); ?&gt;<br />
&lt;?php while (have_posts()) : the_post(); ?&gt;<br />
//the loop here<br />
&lt;?php endwhile;?&gt;<br />
Tips：posts_per_page引数を使うことによって、ページの記事ごとに上書することもできる。（例：query_posts('posts_per_page=6');）

</p>

<h2 id="h2h236">カスタムフィールド</h2>

<p>記事のコンテンツや抜粋と同じように、特別なデータやテキストを記事に加えることができる。

</p>

<p>はじめに記事のカスタムフィールドに追加する。

</p>

<p>記事イメージと記事へのリンクを表示するため、以下のコードをループに入れる。

</p>

<p>&lt;?php //get article_image (custom field) ?&gt;<br />
&lt;?php $image= get_post_meta($post-&gt;ID, 'article_image', true); ?&gt;

</p>

<p>&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot;&gt;&lt;img src=&quot;&lt;?php echo $image; ?&gt;&quot; alt=&quot;&lt;?php the_title(); ?&gt;&quot; /&gt;&lt;/a&gt;<br />
Tips：WordPressでは複数のキーを作り、保存もできる。その上、そのキーはほかの記事にも使うことができる。

</p>

<p>サイトのサムネール、ツールチップのイメージ、URLを表示するために、カスタムフィールド等に使う

</p>

<h2 id="h2h237">リストページ</h2>

<p>wp_list_pagesというテンプレートタグは、ナビゲーションのためにヘッダーやサイバーにページの一覧を表示するために使われる。どのようにwp_list_pagesを用いて、サイトマップやサブメニューを作るのかを示してみよう。

</p>

<h3 id="h3h310">サイトマップ</h3>

<p>全てのページのサイトマップ（サンプル）を作るために、サイトマップのページテンプレートに次のコードを入れよう。（注意：僕はページID12を除外している。なぜならページID12は僕のサイトマップ自身のページであり、そのページを表示する必要がないと思うからだ）。

</p>

<p>&lt;ul&gt;<br />
&lt;?php wp_list_pages('exclude=12&amp;title_li=' ); ?&gt;<br />
&lt;/ul&gt;<br />

</p>

<h3 id="h3h311">ダイナミックサブページメニュー</h3>

<p>サブページにいるとすると、サブページのメニューを出力する。そうするためには、このコードをsidebar.phpに入れよう。

</p>

<p>&lt;?php<br />

</p>

$children= wp_list_pages('title_li=&amp;child_of='.$post-&gt;ID.'&amp;echo=0');
<p>if ($children) { ?&gt;<br />
&lt;ul&gt;<br />
&lt;?php echo $children; ?&gt;<br />
&lt;/ul&gt;<br />
&lt;?php } ?&gt;

</p>

<h2 id="h2h238">ページテンプレート</h2>

<p>WordPressをホームページのように使う

</p>

<p>どのようにページがどのように表示されるべきかを制御するのがページテンプレート機能だ。

</p>

<p>この機能を使うためには、まずページテンプレートを作る必要がある。それから、あるページに特定のテンプレートを指定することができるようになる。

</p>

<p>ページテンプレートがどのように構造化されたのかを示してみよう。（例えば、portfolio.php）

</p>

<p>&lt;?php<br />
/*<br />
Template Name: Portfolio<br />

</p>

<h2 id="h2h239">/</h2>

<p>?&gt;<br />
&lt;?php get_header(); ?&gt;<br />
//the loop here<br />
&lt;?php get_footer(); ?&gt;

</p>

<p>記事を投稿したり編集したりするときに、右側に&quot;Page Template&quot;というタブがあります。<br />
利用できるテンプレートが表示される。

</p>

<h2 id="h2h240">WordPress各種設定</h2>

<p>管理画面には、はじめからたくさんの設定をすることができ、もっとあなたのサイトをよくできる。ここにいくつかあげよう。

</p>

<h3 id="h3h312">トップページをカスタムする</h3>

<p>デフォルトにおいては、WordPressはトップページにあなたの記事を表示する。しかし、もし静的なページ（ようこそやスプラッシュなど）を代わりに使いたいのであれば、管理画面 &gt; 各種設定 &gt; 表示設定から決定することができる。

</p>

<h3 id="h3h313">パーマリンク</h3>

<p>デフォルトのWordPressは記事のURLにwww.yoursite.com/?p=123というものを使っているが、これは検索エンジンにとって好ましいURLではない。パーマリンクは、管理画面 &gt; 各種設定 &gt; パーマリンク設定から変更することができる。個人的には、パーマリンクは/%category%/%postname%/が気に入っている。

</p>

<h2 id="h2h241">カテゴリ接頭語</h2>

<p>デフォルトのWordPressのカテゴリの接頭語は、カテゴリになっている（例：yoursite.com/category/cat-name/）。

</p>

<p>これにarticleをカテゴリーベースに入れることにより（各種設定 &gt; パーマリンク）、カテゴリURLをyoursite.com/article/cat-name/にすることができる。

</p>

]]></content:encoded>
			<wfw:commentRss>http://tenman.info/labo/manual/2009/06/05/%e9%80%86%e5%bc%95%e3%81%8d%e3%80%80%e3%80%80%e3%83%86%e3%83%b3%e3%83%97%e3%83%ac%e3%83%bc%e3%83%88%e3%82%b3%e3%83%bc%e3%83%87%e3%82%a3%e3%83%b3%e3%82%b0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom taxonomies in WordPress 2.8</title>
		<link>http://tenman.info/labo/manual/2009/06/03/custom-taxonomies-in-wordpress-28/</link>
		<comments>http://tenman.info/labo/manual/2009/06/03/custom-taxonomies-in-wordpress-28/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 06:07:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[管理者]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://tenman.info/labo/manual/?p=729</guid>
		<description><![CDATA[引用元: Custom taxonomies in WordPress 2.8.2.8 beta2 ではカスタムタクソノミーが不完全？register_taxonomy でタクソノミーを登録する第一引数は英数字でなければ [...]]]></description>
			<content:encoded><![CDATA[<p>引用元: <a href="http://justintadlock.com/archives/2009/05/06/custom-taxonomies-in-wordpress-28">Custom taxonomies in WordPress 2.8</a>.<a href="http://ja.forums.wordpress.org/topic/1870?replies=8" onclick="this.target='_self';" onkeypress="this.target='_self';">2.8 beta2 ではカスタムタクソノミーが不完全？</a><ul><li>register_taxonomy でタクソノミーを登録する</li><li>第一引数は英数字でなければならない</li><li>wp_rewrite を register_activation_hook の時に flush する</li></ul><a href="http://www.simonwheatley.co.uk/2009/03/11/custom-taxonomies-in-wordpress/" onclick="this.target='_self';" onkeypress="this.target='_self';">Custom taxonomies in WordPress</a>

</p>

]]></content:encoded>
			<wfw:commentRss>http://tenman.info/labo/manual/2009/06/03/custom-taxonomies-in-wordpress-28/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>年別アーカイブ一覧表示</title>
		<link>http://tenman.info/labo/manual/2009/06/03/%e5%b9%b4%e5%88%a5%e3%82%a2%e3%83%bc%e3%82%ab%e3%82%a4%e3%83%96%e4%b8%80%e8%a6%a7%e8%a1%a8%e7%a4%ba/</link>
		<comments>http://tenman.info/labo/manual/2009/06/03/%e5%b9%b4%e5%88%a5%e3%82%a2%e3%83%bc%e3%82%ab%e3%82%a4%e3%83%96%e4%b8%80%e8%a6%a7%e8%a1%a8%e7%a4%ba/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 05:45:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[管理者]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://tenman.info/labo/manual/?p=725</guid>
		<description><![CDATA[
年別アーカイブのタイトル一覧表示


&#60;?php if &#40;have_posts&#40;&#41;&#41; : ?&#62;
&#60;dl class=&#34;archives&#34;&#62;
&#038; [...]]]></description>
			<content:encoded><![CDATA[
<a href="http://ja.forums.wordpress.org/topic/1876?replies=6" onclick="this.target='_self';" onkeypress="this.target='_self';">年別アーカイブのタイトル一覧表示</a>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #ff0000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #ff0000; font-weight: bold;">?&gt;</span>
&lt;dl class=&quot;archives&quot;&gt;
<span style="color: #ff0000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #ff0000; font-weight: bold;">?&gt;</span>
<span style="color: #ff0000; font-weight: bold;">&lt;?php</span> the_date<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$date_format</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;dt&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/dt&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #ff0000; font-weight: bold;">?&gt;</span>
&lt;dd&gt;&lt;a href=&quot;<span style="color: #ff0000; font-weight: bold;">&lt;?php</span> the_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #ff0000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #ff0000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #ff0000; font-weight: bold;">?&gt;</span>&lt;/a&gt;&lt;/dd&gt;
<span style="color: #ff0000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #ff0000; font-weight: bold;">?&gt;</span>
&lt;/dl&gt;
<span style="color: #ff0000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">else</span><span style="color: #339933;">:</span> <span style="color: #ff0000; font-weight: bold;">?&gt;</span>
&lt;p&gt;指定された年度の投稿はありません。&lt;/p&gt;
<span style="color: #ff0000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #ff0000; font-weight: bold;">?&gt;</span></pre></div></div>


]]></content:encoded>
			<wfw:commentRss>http://tenman.info/labo/manual/2009/06/03/%e5%b9%b4%e5%88%a5%e3%82%a2%e3%83%bc%e3%82%ab%e3%82%a4%e3%83%96%e4%b8%80%e8%a6%a7%e8%a1%a8%e7%a4%ba/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ブログロールの説明の文字数制限</title>
		<link>http://tenman.info/labo/manual/2009/05/28/%e3%83%96%e3%83%ad%e3%82%b0%e3%83%ad%e3%83%bc%e3%83%ab%e3%81%ae%e8%aa%ac%e6%98%8e%e3%81%ae%e6%96%87%e5%ad%97%e6%95%b0%e5%88%b6%e9%99%90/</link>
		<comments>http://tenman.info/labo/manual/2009/05/28/%e3%83%96%e3%83%ad%e3%82%b0%e3%83%ad%e3%83%bc%e3%83%ab%e3%81%ae%e8%aa%ac%e6%98%8e%e3%81%ae%e6%96%87%e5%ad%97%e6%95%b0%e5%88%b6%e9%99%90/#comments</comments>
		<pubDate>Thu, 28 May 2009 00:44:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[管理者]]></category>
		<category><![CDATA[制限・お約束]]></category>

		<guid isPermaLink="false">http://tenman.info/labo/manual/?p=681</guid>
		<description><![CDATA[



DB の定義で、link_description は VARCHAR(255) となっているため、本来は 255 文字まで行けるはずです (MySQL 4.1 以降で照合順序が utf8_general_ci の [...]]]></description>
			<content:encoded><![CDATA[<img src="http://tenman.info/labo/manual/files/crome.png" alt="crome" title="crome" width="70" height="70" class="alignnone size-full wp-image-698" />

<blockquote>

DB の定義で、link_description は VARCHAR(255) となっているため、本来は 255 文字まで行けるはずです (MySQL 4.1 以降で照合順序が utf8_general_ci の場合)。VARCHAR はバイト数じゃなくて文字数の制限だからです。しかし、日本語は UTF-8 で1文字3バイトのため、WordPress のどこかで link_description の長さチェックをバイト数で行なっていると、81 文字しか入らなくなります。

</blockquote>

<script>test</script>

<blockquote>

link_descriptionのフィールドタイプをVARCHARからTEXTに変更しましたら、思い通りに文字数の制限がなくなりました。

</blockquote>

<a href="http://ja.forums.wordpress.org/topic/456?replies=6" onclick="this.target='_self';" onkeypress="this.target='_self';">WordPress &amp;#8250; フォーラム &amp;raquo; ブログロールの説明の文字数制限について</a>

]]></content:encoded>
			<wfw:commentRss>http://tenman.info/labo/manual/2009/05/28/%e3%83%96%e3%83%ad%e3%82%b0%e3%83%ad%e3%83%bc%e3%83%ab%e3%81%ae%e8%aa%ac%e6%98%8e%e3%81%ae%e6%96%87%e5%ad%97%e6%95%b0%e5%88%b6%e9%99%90/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>bookmark</title>
		<link>http://tenman.info/labo/manual/2009/05/27/bookmark/</link>
		<comments>http://tenman.info/labo/manual/2009/05/27/bookmark/#comments</comments>
		<pubDate>Wed, 27 May 2009 13:15:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[管理者]]></category>

		<guid isPermaLink="false">http://tenman.info/labo/manual/?p=672</guid>
		<description><![CDATA[wordPressは、管理画面の　「リンク」から、外部のWEBサイトなどをリンクし、カテゴリ別に整理する機能が付いています。



工夫して使うと、意外と便利です。



そのままでも使えますが、サイドバーに配置するだけ [...]]]></description>
			<content:encoded><![CDATA[<p>wordPressは、管理画面の　「リンク」から、外部のWEBサイトなどをリンクし、カテゴリ別に整理する機能が付いています。

</p>

<p>工夫して使うと、意外と便利です。

</p>

<p>そのままでも使えますが、サイドバーに配置するだけでなく、テンプレートファイルを作成して、ページにリンク集のような使い方もできます。

</p>

テンプレートファイルのコーディングに関する情報は、<a href="http://wpdocs.sourceforge.jp/%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%82%BF%E3%82%B0/wp_list_bookmarks" onclick="this.target='_self';" onkeypress="this.target='_self';">テンプレートタグ/wp list bookmarks</a>に整理されているようです。このブログでは、<a href="http://tenman.info/labo/manual/link/" onclick="this.target='_self';" onkeypress="this.target='_self';">FAQ &amp;raquo; link</a>がカスタマイズ事例です。ブックマークレットと併用すると、ソーシャルブックマークの感覚で利用する事ができます。<a href="http://text2html.s321.xrea.com/wp/wordpress/2009/05/22/%E3%83%AA%E3%83%B3%E3%82%AF%E3%83%9A%E3%83%BC%E3%82%B8%E7%94%A8%E3%81%AE%E3%83%96%E3%83%83%E3%82%AF%E3%83%9E%E3%83%BC%E3%82%AF%E3%83%AC%E3%83%83%E3%83%88/" onclick="this.target='_self';" onkeypress="this.target='_self';">ブックマークレットについての情報は、こちらを参照してください</a>

]]></content:encoded>
			<wfw:commentRss>http://tenman.info/labo/manual/2009/05/27/bookmark/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>検索フォームの表示する</title>
		<link>http://tenman.info/labo/manual/2009/05/27/%e6%a4%9c%e7%b4%a2%e3%83%95%e3%82%a9%e3%83%bc%e3%83%a0%e3%81%ae%e8%a1%a8%e7%a4%ba%e3%81%99%e3%82%8b/</link>
		<comments>http://tenman.info/labo/manual/2009/05/27/%e6%a4%9c%e7%b4%a2%e3%83%95%e3%82%a9%e3%83%bc%e3%83%a0%e3%81%ae%e8%a1%a8%e7%a4%ba%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Wed, 27 May 2009 02:43:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[管理者]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://tenman.info/labo/manual/?p=659</guid>
		<description><![CDATA[テンプレートファイルに、ワードプレスのテンプレート関数を記述すると、検索フォームを設置する事ができます。





&#60;?php get_search_form(); ?&#62; このコードをテンプレートファイルの任 [...]]]></description>
			<content:encoded><![CDATA[<p>テンプレートファイルに、ワードプレスのテンプレート関数を記述すると、検索フォームを設置する事ができます。

</p>

<pre id="presouce1">

<code title="line1">&lt;?php get_search_form(); ?&gt; このコードをテンプレートファイルの任意の位置に貼り付けます。</code>
</pre>
<!---->

]]></content:encoded>
			<wfw:commentRss>http://tenman.info/labo/manual/2009/05/27/%e6%a4%9c%e7%b4%a2%e3%83%95%e3%82%a9%e3%83%bc%e3%83%a0%e3%81%ae%e8%a1%a8%e7%a4%ba%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>the_date()とthe_time()ワードプレス　テンプレート関数の使い方</title>
		<link>http://tenman.info/labo/manual/2009/05/27/the_date%e3%81%a8the_time%e3%83%af%e3%83%bc%e3%83%89%e3%83%97%e3%83%ac%e3%82%b9%e9%96%a2%e6%95%b0%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9/</link>
		<comments>http://tenman.info/labo/manual/2009/05/27/the_date%e3%81%a8the_time%e3%83%af%e3%83%bc%e3%83%89%e3%83%97%e3%83%ac%e3%82%b9%e9%96%a2%e6%95%b0%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9/#comments</comments>
		<pubDate>Wed, 27 May 2009 01:23:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[管理者]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://tenman.info/labo/manual/?p=653</guid>
		<description><![CDATA[テンプレートループ内で利用する　日時タグの代表的なものに、the_dateとthe_timeがあります。


日付の表示の仕方が異なります。
the_dateは、1ページに同一投稿日の記事があれば、その最初の記事にのみ表 [...]]]></description>
			<content:encoded><![CDATA[テンプレートループ内で利用する　日時タグの代表的なものに、<a href="http://wpdocs.sourceforge.jp/%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%82%BF%E3%82%B0/the_date" onclick="this.target='_self';" onkeypress="this.target='_self';">the_date</a>と<a href="http://wpdocs.sourceforge.jp/%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%82%BF%E3%82%B0/the_time" onclick="this.target='_self';" onkeypress="this.target='_self';">the_time</a>があります。

<div class="tips">
<p>日付の表示の仕方が異なります。<br />
the_dateは、1ページに同一投稿日の記事があれば、その最初の記事にのみ表示<br />
the_timeは、1ページに同一投稿日の記事があれば、すべての記事に表示<br />

</p>

<small>日時の出力形式。PHPの日付文法が使用できる。デフォルト値は管理画面のオプションで設定した形式</small>

</div>

]]></content:encoded>
			<wfw:commentRss>http://tenman.info/labo/manual/2009/05/27/the_date%e3%81%a8the_time%e3%83%af%e3%83%bc%e3%83%89%e3%83%97%e3%83%ac%e3%82%b9%e9%96%a2%e6%95%b0%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>カスタムフィールド</title>
		<link>http://tenman.info/labo/manual/2009/05/27/%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e3%83%95%e3%82%a3%e3%83%bc%e3%83%ab%e3%83%89/</link>
		<comments>http://tenman.info/labo/manual/2009/05/27/%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e3%83%95%e3%82%a3%e3%83%bc%e3%83%ab%e3%83%89/#comments</comments>
		<pubDate>Tue, 26 May 2009 23:47:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[用語]]></category>
		<category><![CDATA[管理者]]></category>
		<category><![CDATA[カスタムフィールド]]></category>
		<category><![CDATA[全般]]></category>

		<guid isPermaLink="false">http://tenman.info/labo/manual/?p=641</guid>
		<description><![CDATA[
カスタムフィールドの使い方

カスタムフィールドを使って、テンプレートファイルをカスタマイズすると、通常投稿タイトルや、本文が表示される場所以外に、自分の思い通りの場所に、特別に、投稿エリアを設定する事ができます。

 [...]]]></description>
			<content:encoded><![CDATA[
<a href="http://wpdocs.sourceforge.jp/%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%A0%E3%83%95%E3%82%A3%E3%83%BC%E3%83%AB%E3%83%89%E3%81%AE%E4%BD%BF%E3%81%84%E6%96%B9" onclick="this.target='_self';" onkeypress="this.target='_self';">カスタムフィールドの使い方</a>

<p>カスタムフィールドを使って、テンプレートファイルをカスタマイズすると、通常投稿タイトルや、本文が表示される場所以外に、自分の思い通りの場所に、特別に、投稿エリアを設定する事ができます。

</p>

<p>カスタムフィールドは、管理画面の投稿フォームに、いつでも新規投稿と、編集が可能なように用意されています。

</p>

<pre id="presouce1">

<code title="line1">&lt;?php the_meta(); ?&gt;</code>
</pre>
<p>というコードを、テンプレートファイルに貼り付けることで表示できるようになります。<br />
貼り付ける場所によって、カスタムフィールドが表示されない事がありますから、<br />
よくわからないときには、テンプレートファイルの、the_post();の部分を探して、<br />

</p>

<pre id="presouce2">

<code title="line1">the_post(); the_meta();</code>
</pre>
<p>に書き換えて表示してみましょう。

</p>

]]></content:encoded>
			<wfw:commentRss>http://tenman.info/labo/manual/2009/05/27/%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e3%83%95%e3%82%a3%e3%83%bc%e3%83%ab%e3%83%89/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>カスタムフィールドの「値だけ表示する」</title>
		<link>http://tenman.info/labo/manual/2009/05/27/%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e3%83%95%e3%82%a3%e3%83%bc%e3%83%ab%e3%83%89%e3%81%ae%e3%80%8c%e5%80%a4%e3%81%a0%e3%81%91%e8%a1%a8%e7%a4%ba%e3%81%99%e3%82%8b%e3%80%8d/</link>
		<comments>http://tenman.info/labo/manual/2009/05/27/%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e3%83%95%e3%82%a3%e3%83%bc%e3%83%ab%e3%83%89%e3%81%ae%e3%80%8c%e5%80%a4%e3%81%a0%e3%81%91%e8%a1%a8%e7%a4%ba%e3%81%99%e3%82%8b%e3%80%8d/#comments</comments>
		<pubDate>Tue, 26 May 2009 23:43:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[styling]]></category>
		<category><![CDATA[管理者]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[カスタムフィールド]]></category>

		<guid isPermaLink="false">http://tenman.info/labo/manual/?p=638</guid>
		<description><![CDATA[post_custom() 

the_meta()によって、すべてのカスタムフィールドのキーと値が表示されているときには、





&#60;?php echo post_custom('key'); ?&#62;を使う [...]]]></description>
			<content:encoded><![CDATA[<h2 id="h2h21">post_custom() </h2>

<p>the_meta()によって、すべてのカスタムフィールドのキーと値が表示されているときには、

</p>

<pre id="presouce1">

<code title="line1">&lt;?php echo post_custom('key'); ?&gt;を使う方法があります。</code>
</pre>

<p>また、複数（の可能性がある）カスタムフィールドを表示する場合は、以下のようにしてもよいかもしれない。

</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #ff0000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #ff0000; font-weight: bold;">?&gt;</span>
<span style="color: #ff0000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$mywords</span> <span style="color: #339933;">=</span> post_custom<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'key'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mywords</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #990000;">echo</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$separator</span><span style="color: #339933;">,</span> <span style="color: #000088;">$mywords</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #990000;">echo</span> <span style="color: #000088;">$mywords</span> <span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #ff0000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #ff0000; font-weight: bold;">?&gt;</span></pre></div></div>


]]></content:encoded>
			<wfw:commentRss>http://tenman.info/labo/manual/2009/05/27/%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e3%83%95%e3%82%a3%e3%83%bc%e3%83%ab%e3%83%89%e3%81%ae%e3%80%8c%e5%80%a4%e3%81%a0%e3%81%91%e8%a1%a8%e7%a4%ba%e3%81%99%e3%82%8b%e3%80%8d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>特定の親カテゴリを持つ、カテゴリのデザインを統一する。</title>
		<link>http://tenman.info/labo/manual/2009/05/26/%e7%89%b9%e5%ae%9a%e3%81%ae%e8%a6%aa%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e3%82%92%e6%8c%81%e3%81%a4%e3%80%81%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e3%81%ae%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%82%92/</link>
		<comments>http://tenman.info/labo/manual/2009/05/26/%e7%89%b9%e5%ae%9a%e3%81%ae%e8%a6%aa%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e3%82%92%e6%8c%81%e3%81%a4%e3%80%81%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e3%81%ae%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%82%92/#comments</comments>
		<pubDate>Tue, 26 May 2009 05:59:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[管理者]]></category>
		<category><![CDATA[設定]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://tenman.info/labo/manual/?p=615</guid>
		<description><![CDATA[WordPress › フォーラム » 指定のカテゴリーの子カテゴリーを全て同じデザインにする.



cat_is_ancestor_ofは、２つの引数を指定する必要があり、第１引数に指定されたカテゴリーが第２引数にて [...]]]></description>
			<content:encoded><![CDATA[<a href="http://ja.forums.wordpress.org/topic/1668">WordPress › フォーラム » 指定のカテゴリーの子カテゴリーを全て同じデザインにする</a>.

<blockquote>

cat_is_ancestor_ofは、２つの引数を指定する必要があり、第１引数に指定されたカテゴリーが第２引数にて指定されたカテゴリーの先祖にあたるかどうかを真偽値で返します。kiwさんの場合、イベント情報のカテゴリーIDが３だとして、イベント情報のテンプレートをevent_info.phpにて表示する場合、カテゴリーが表示されるテンプレートの最初に下記の様に記述すれば、イベント情報以下のカテゴリーではevent_info.phpにて表示され、それ以外では、デフォルトのテンプレートにて表示されるようになるかと思います。

</blockquote>

5b57394f04f44b6ffa7e5086e7753b51005<a href="http://ja.forums.wordpress.org/topic/1290" onclick="this.target='_self';" onkeypress="this.target='_self';">条件分岐</a>

]]></content:encoded>
			<wfw:commentRss>http://tenman.info/labo/manual/2009/05/26/%e7%89%b9%e5%ae%9a%e3%81%ae%e8%a6%aa%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e3%82%92%e6%8c%81%e3%81%a4%e3%80%81%e3%82%ab%e3%83%86%e3%82%b4%e3%83%aa%e3%81%ae%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%82%92/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
