WordPressテーマカスタマイズ&XML出力2010/1/16フリーランスシステムエンジニア上村 崇
はじめに
このプレゼンは後で公開しますので書き写す必要はありません
質問は随時、挙手で
それでは本題
まずはじめに、WordPressのテーマをカスタマイズする方法についてつぎに、XMLファイルを出力する方法について
WordPressとは
ブログツールの一つ
PHPで作られています
MySQLを使っています
創始者Matt Mullenweg氏26歳
ブログツール比較日本全世界
CMS比較日本全世界
WordPressが2009年のベストCMS賞を獲得
テーマについて
テーマは無数にあります
テーマをカスタマイズしましょう!
もちろんHTMLスタイルシートの知識は必要ですが
WordPressディレクトリ構成PHPテンプレートテンプレートタグ
WordPressディレクトリ構成
themesclassic初期状態でテーマは2つ
themesdefaultとりあえずテーマファイルの置き場所だけ知っていればいいです
PHPの基本
まず、普通のHTMLファイルはこんなのです。
index.html<html> <head><title>文書のタイトル</title></head><body>         文書の本文</body> </html>
同じことをPHPでやると、こうなります。
index.php<?phpecho "<html>";echo "    <head>";echo "        <title>文書のタイトル</title>";echo "    </head>";echo "    <body>";echo "文書の本文";echo "    </body>";echo "</html>";?>
別の方法もあります。
index.php<?php    $title          = "文書のタイトル";    $contents = "文書の本文";?><html>     <head>        <title><?phpecho $title ?></title>    </head>    <body> <?phpecho $contents ?>    </body> </html>
つまり、PHPを書くときは<?php  ?> で囲む
テンプレートとテンプレートタグ
ブロックに分けて考えてみます
headermaincontentssidebarfooter
コードで表すとこうなります->
index.php<?phpget_header();?>	<?phpif ( have_posts() ) : ?><?phpwhile (have_posts()) : the_post(); ?><?phpendwhile;?>	<?phpelse :?>	<?phpendif; ?><?phpget_sidebar(); ?><?phpget_footer();?>
index.php<?phpget_header();?>	<?phpif ( have_posts() ) : ?><?phpwhile (have_posts()) : the_post(); ?><?phpendwhile;?>	<?phpelse :?>	<?phpendif; ?><?phpget_sidebar(); ?><?phpget_footer();?>WordPressループ(Main Contents)
index.php<?phpget_header();?>	<?phpif ( have_posts() ) : ?><?phpwhile (have_posts()) : the_post(); ?><?phpendwhile;?>	<?phpelse :?>	<?phpendif; ?><?phpget_sidebar(); ?><?phpget_footer();?>headermaincontentssidebarfooter
index.php<?phpget_header();?>	<?phpif ( have_posts() ) : ?><?phpwhile (have_posts()) : the_post(); ?><?phpendwhile;?>	<?phpelse :?>	<?phpendif; ?><?phpget_sidebar(); ?><?phpget_footer();?>headermaincontentssidebarfooter
index.php<?phpget_header();?>	<?phpif ( have_posts() ) : ?><?phpwhile (have_posts()) : the_post(); ?><?phpendwhile;?>	<?phpelse :?>	<?phpendif; ?><?phpget_sidebar(); ?><?phpget_footer();?>headermaincontentssidebarfooter
index.php<?phpget_header();?>	<?phpif ( have_posts() ) : ?><?phpwhile (have_posts()) : the_post(); ?><?phpendwhile;?>	<?phpelse :?>	<?phpendif; ?><?phpget_sidebar(); ?><?phpget_footer();?>headermaincontentssidebarfooter
index.php<?phpget_header();?>	<?phpif ( have_posts() ) : ?><?phpwhile (have_posts()) : the_post(); ?><?phpendwhile;?>	<?phpelse :?>	<?phpendif; ?><?phpget_sidebar(); ?><?phpget_footer();?>テンプレートタグWordPress組込の関数
index.phpheader.php<?phpget_header();?>	<?phpif ( have_posts() ) : ?><?phpwhile (have_posts()) : the_post(); ?><?phpendwhile;?>	<?phpelse :?>	<?phpendif; ?><?phpget_sidebar(); ?><?phpget_footer();?>sidebar.phpfooter.php
defaultテンプレート
Headerについて詳しく見てみます。
header
header.php<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" <?phplanguage_attributes(); ?>><head><meta http-equiv="Content-Type" content="<?phpbloginfo('html_type'); ?>; charset=<?phpbloginfo('charset'); ?>" /><title>    <?phpwp_title('«', true, 'right'); ?>    <?phpbloginfo('name'); ?></title><link rel="stylesheet" href="<?phpbloginfo('stylesheet_url'); ?>" type="text/css” /><style type="text/css”>    #page { background: url("<?phpbloginfo('stylesheet_directory'); ?>/images/kubrickbg-ltr.jpg“) }</style><?phpwp_head(); ?></head><body><div id="page"><div id="header" role="banner"><div id="headerimg"><h1><a href="<?php echo get_option('home'); ?>/"><?phpbloginfo('name'); ?></a></h1><div class="description"><?phpbloginfo('description'); ?></div></div></div>
header.php<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" <?phplanguage_attributes(); ?>><head><meta http-equiv="Content-Type" content="<?phpbloginfo('html_type'); ?>; charset=<?phpbloginfo('charset'); ?>" /><title>    <?phpwp_title('«', true, 'right'); ?>    <?phpbloginfo('name'); ?></title><link rel="stylesheet" href="<?phpbloginfo('stylesheet_url'); ?>" type="text/css” /><style type="text/css”>    #page { background: url("<?phpbloginfo('stylesheet_directory'); ?>/images/kubrickbg-ltr.jpg“) }</style><?phpwp_head(); ?></head><body><div id="page"><div id="header" role="banner"><div id="headerimg"><h1><a href="<?php echo get_option('home'); ?>/"><?phpbloginfo('name'); ?></a></h1><div class="description"><?phpbloginfo('description'); ?></div></div></div>URLタイトルサイトの説明
URLタイトルサイトの説明
header.php<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" <?phplanguage_attributes(); ?>><head><meta http-equiv="Content-Type" content="<?phpbloginfo('html_type'); ?>; charset=<?phpbloginfo('charset'); ?>" /><title>    <?phpwp_title('«', true, 'right'); ?>    <?phpbloginfo('name'); ?></title><link rel="stylesheet" href="<?phpbloginfo('stylesheet_url'); ?>" type="text/css” /><style type="text/css”>    #page { background: url("<?phpbloginfo('stylesheet_directory'); ?>/images/kubrickbg-ltr.jpg“) }</style><?phpwp_head(); ?></head><body><div id="page"><div id="header" role="banner"><div id="headerimg"><h1><a href="<?php echo get_option('home'); ?>/"><?phpbloginfo('name'); ?></a></h1><div class="description"><?phpbloginfo('description'); ?></div></div></div>
header.php<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" <?phplanguage_attributes(); ?>><head><meta http-equiv="Content-Type" content="<?phpbloginfo('html_type'); ?>; charset=<?phpbloginfo('charset'); ?>" /><title>    <?phpwp_title('«', true, 'right'); ?>    <?phpbloginfo('name'); ?></title><link rel="stylesheet" href="<?phpbloginfo('stylesheet_url'); ?>" type="text/css” /><style type="text/css”>    #page { background: url("<?phpbloginfo('stylesheet_directory'); ?>/images/kubrickbg-ltr.jpg“) }</style><?phpwp_head(); ?></head><body><div id="page"><div id="header" role="banner"><div id="headerimg"><h1><a href="<?php echo get_option('home'); ?>/"><?phpbloginfo('name'); ?></a></h1><div class="description"><?phpbloginfo('description'); ?></div></div></div>ドキュメントの場所は?
wordpresscodex検 索
次に、WordPressループの説明
index.phpWordPressループ(Main Contents)<?phpget_header();?>	<?phpif ( have_posts() ) : ?><?phpwhile (have_posts()) : the_post(); ?><?phpendwhile;?>	<?phpelse :?>	<?phpendif; ?><?phpget_sidebar(); ?><?phpget_footer();?>headermaincontentssidebarfooter
繰り返し記事タイトル日付本文カテゴリ、コメント
WordPressループ<?phpif (have_posts()) : ?><?phpwhile (have_posts()) : the_post(); ?><div <?phppost_class(); ?> id="post-<?phpthe_ID(); ?>"><h2><a href="<?phpthe_permalink()?>“ ><?phpthe_title(); ?></a></h2><small><?phpthe_time(__('F jS, Y', 'kubrick'))?></small><div class="entry"><?phpthe_content(__('Read the rest of this entry »', 'kubrick')); ?></div><p class="postmetadata"><?phpprintf(__('Posted in %s', 'kubrick'), get_the_category_list(', ')); ?> | <?phpedit_post_link(__('Edit', 'kubrick'), '', ' | '); ?> <?phpcomments_popup_link(__('No Comments »', 'kubrick'), __('1 Comment »', 'kubrick'), __('% Comments »', 'kubrick'), '',__('Comments Closed', 'kubrick') ); ?></p></div><?phpendwhile; ?><?phpelse : ?><h2 class="center"><?php _e('Not Found', 'kubrick'); ?></h2><p class="center"><?php _e('Sorry, but you are looking for something that isn’t here.', 'kubrick'); ?></p><?phpget_search_form(); ?><?phpendif; ?>
<?phpif (have_posts()) : ?><?phpwhile (have_posts()) : the_post(); ?><div <?phppost_class(); ?> id="post-<?phpthe_ID(); ?>"><h2><a href="<?phpthe_permalink()?>“ ><?phpthe_title(); ?></a></h2><small><?phpthe_time(__('F jS, Y', 'kubrick'))?></small><div class="entry"><?phpthe_content(__('Read the rest of this entry »', 'kubrick')); ?></div><p class="postmetadata"><?phpprintf(__('Posted in %s', 'kubrick'), get_the_category_list(', ')); ?> | <?phpedit_post_link(__('Edit', 'kubrick'), '', ' | '); ?> <?phpcomments_popup_link(__('No Comments »', 'kubrick'), __('1 Comment »', 'kubrick'), __('% Comments »', 'kubrick'), '',__('Comments Closed', 'kubrick') ); ?></p></div><?phpendwhile; ?><?phpelse : ?><h2 class="center"><?php _e('Not Found', 'kubrick'); ?></h2><p class="center"><?php _e('Sorry, but you are looking for something that isn’t here.', 'kubrick'); ?></p><?phpget_search_form(); ?><?phpendif; ?>投稿があればtrue、なければfalse投稿がある場合の処理投稿がない場合の処理
<?phpif (have_posts()) : ?><?phpwhile (have_posts()) : the_post(); ?><div <?phppost_class(); ?> id="post-<?phpthe_ID(); ?>"><h2><a href="<?phpthe_permalink()?>“ ><?phpthe_title(); ?></a></h2><small><?phpthe_time(__('F jS, Y', 'kubrick'))?></small><div class="entry"><?phpthe_content(__('Read the rest of this entry »', 'kubrick')); ?></div><p class="postmetadata"><?phpprintf(__('Posted in %s', 'kubrick'), get_the_category_list(', ')); ?> | <?phpedit_post_link(__('Edit', 'kubrick'), '', ' | '); ?> <?phpcomments_popup_link(__('No Comments »', 'kubrick'), __('1 Comment »', 'kubrick'), __('% Comments »', 'kubrick'), '',__('Comments Closed', 'kubrick') ); ?></p></div><?phpendwhile; ?><?phpelse : ?><h2 class="center"><?php _e('Not Found', 'kubrick'); ?></h2><p class="center"><?php _e('Sorry, but you are looking for something that isn’t here.', 'kubrick'); ?></p><?phpget_search_form(); ?><?phpendif; ?>投稿がある場合の処理
<?phpif (have_posts()) : ?><?phpwhile (have_posts()) : the_post(); ?><div <?phppost_class(); ?> id="post-<?phpthe_ID(); ?>"><h2><a href="<?phpthe_permalink()?>“ ><?phpthe_title(); ?></a></h2><small><?phpthe_time(__('F jS, Y', 'kubrick'))?></small><div class="entry"><?phpthe_content(__('Read the rest of this entry »', 'kubrick')); ?></div><p class="postmetadata"><?phpprintf(__('Posted in %s', 'kubrick'), get_the_category_list(', ')); ?> | <?phpedit_post_link(__('Edit', 'kubrick'), '', ' | '); ?> <?phpcomments_popup_link(__('No Comments »', 'kubrick'), __('1 Comment »', 'kubrick'), __('% Comments »', 'kubrick'), '',__('Comments Closed', 'kubrick') ); ?></p></div><?phpendwhile; ?><?phpelse : ?><h2 class="center"><?php _e('Not Found', 'kubrick'); ?></h2><p class="center"><?php _e('Sorry, but you are looking for something that isn’t here.', 'kubrick'); ?></p><?phpget_search_form(); ?><?phpendif; ?>投稿がある間Loopする投稿1つ分の準備投稿の数だけループ
<?phpif (have_posts()) : ?><?phpwhile (have_posts()) : the_post(); ?><div <?phppost_class(); ?> id="post-<?phpthe_ID(); ?>"><h2><a href="<?phpthe_permalink()?>“ ><?phpthe_title(); ?></a></h2><small><?phpthe_time(__('F jS, Y', 'kubrick'))?></small><div class="entry"><?phpthe_content(__('Read the rest of this entry »', 'kubrick')); ?></div><p class="postmetadata"><?phpprintf(__('Posted in %s', 'kubrick'), get_the_category_list(', ')); ?> | <?phpedit_post_link(__('Edit', 'kubrick'), '', ' | '); ?> <?phpcomments_popup_link(__('No Comments »', 'kubrick'), __('1 Comment »', 'kubrick'), __('% Comments »', 'kubrick'), '',__('Comments Closed', 'kubrick') ); ?></p></div><?phpendwhile; ?><?phpelse : ?><h2 class="center"><?php _e('Not Found', 'kubrick'); ?></h2><p class="center"><?php _e('Sorry, but you are looking for something that isn’t here.', 'kubrick'); ?></p><?phpget_search_form(); ?><?phpendif; ?>タイトル本文全部理解しないといけないの?
・すべてのコードを理解する必要はない。・イメージにあったテーマを見つけてきて、     それをカスタマイズすればよい。
default他のファイルは?
← not foundページ    アーカイブページ    コメントページ← 共通関数用← 画像一覧ページdefault    言語関連ファイル← リンクページ← 特定の1ページ← テーマのスクリーンショット← 検索ページ← 1投稿分の詳細ページ
テーマのカスタマイズ方法終わり
つぎに、XMLファイルを出力する方法について
「MTだったらXMLの書き出しが比較的簡単に出来るんですが WPだとなかなか難しいみたいで、僕の希望としましてはWPを使ってXMLの簡単な 書き出し方法があればご教授頂きたいなと思います。RSSやFlashに使うときに便利なので・・・。」
最新の投稿一覧カテゴリー毎一覧XML
最新の投稿一覧カテゴリー毎一覧XML作る
仕様:最新の投稿5件をXMLファイルに出力します。・日付・タイトル・投稿内容・カテゴリ
最新の投稿を出す方法はindex.phpを参考にできる
XML出力イメージ・・・
Step1:XMLを出力するコードを作成します
<?php/*Template Name: XmlForFlash*/?><?php header('Content-Type: text/xml; charset='.get_option('blog_charset'), true); ?><?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.‘>’; ?><root><?phpquery_posts("posts_per_page=5"); ?><?phpif (have_posts()) : ?><?phpwhile (have_posts()) : the_post(); ?><item><title><![CDATA[<?php echo the_title_rss(); ?>]]></title><pubdate><?php echo the_time('Y-m-d H:i:s’); ?></pubdate><?phpthe_category_rss(); ?><description><![CDATA[<?phpthe_content_rss(); ?>]]></description></item><?phpendwhile; ?><?phpendif; ?></root><?xml version="1.0" encoding=“UTF-8” ?>タイトル時  刻<category></category>カテゴリ本文内容テンプレートタグで書くと?
<?php/*Template Name: XmlForFlash*/?><?php header('Content-Type: text/xml; charset='.get_option('blog_charset'), true); ?><?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.‘>’; ?><root><?phpquery_posts("posts_per_page=5"); ?><?phpif (have_posts()) : ?><?phpwhile (have_posts()) : the_post(); ?><item><title><![CDATA[<?php echo the_title_rss(); ?>]]></title><pubdate><?php echo the_time('Y-m-d H:i:s’); ?></pubdate><?phpthe_category_rss(); ?><description><![CDATA[<?phpthe_content_rss(); ?>]]></description></item><?phpendwhile; ?><?phpendif; ?></root>続いてループ処理を挿入->
<?php/*Template Name: XmlForFlash*/?><?php header('Content-Type: text/xml; charset='.get_option('blog_charset'), true); ?><?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.‘>’; ?><root><?phpquery_posts("posts_per_page=5"); ?><?phpif (have_posts()) : ?><?phpwhile (have_posts()) : the_post(); ?><item><title><![CDATA[<?php echo the_title_rss(); ?>]]></title><pubdate><?php echo the_time('Y-m-d H:i:s’); ?></pubdate><?phpthe_category_rss(); ?><description><![CDATA[<?phpthe_content_rss(); ?>]]></description></item><?phpendwhile; ?><?phpendif; ?></root>最新の5件を取得->
<?php/*Template Name: XmlForFlash*/?><?php header('Content-Type: text/xml; charset='.get_option('blog_charset'), true); ?><?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.‘>’; ?><root><?phpquery_posts("posts_per_page=5"); ?><?phpif (have_posts()) : ?><?phpwhile (have_posts()) : the_post(); ?><item><title><![CDATA[<?php echo the_title_rss(); ?>]]></title><pubdate><?php echo the_time('Y-m-d H:i:s’); ?></pubdate><?phpthe_category_rss(); ?><description><![CDATA[<?phpthe_content_rss(); ?>]]></description></item><?phpendwhile; ?><?phpendif; ?></root>
default新規作成
Step2:ファイルをWordPressに登録します
①外観 > 編集②作ったテンプレートファイルがエントリされていることを確認
①ページ > 新規追加②タイトルを入れる③XmlForFlashを選択する
保存するとURLが得られます。
完成!

20100116 01 Word Pressテンプレートのカスタマイズ&Xml出力

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
    index.php<?phpecho "<html>";echo " <head>";echo " <title>文書のタイトル</title>";echo " </head>";echo " <body>";echo "文書の本文";echo " </body>";echo "</html>";?>
  • 36.
  • 37.
    index.php<?php $title = "文書のタイトル"; $contents = "文書の本文";?><html> <head> <title><?phpecho $title ?></title> </head> <body> <?phpecho $contents ?> </body> </html>
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
    index.php<?phpget_header();?> <?phpif ( have_posts()) : ?><?phpwhile (have_posts()) : the_post(); ?><?phpendwhile;?> <?phpelse :?> <?phpendif; ?><?phpget_sidebar(); ?><?phpget_footer();?>
  • 44.
    index.php<?phpget_header();?> <?phpif ( have_posts()) : ?><?phpwhile (have_posts()) : the_post(); ?><?phpendwhile;?> <?phpelse :?> <?phpendif; ?><?phpget_sidebar(); ?><?phpget_footer();?>WordPressループ(Main Contents)
  • 45.
    index.php<?phpget_header();?> <?phpif ( have_posts()) : ?><?phpwhile (have_posts()) : the_post(); ?><?phpendwhile;?> <?phpelse :?> <?phpendif; ?><?phpget_sidebar(); ?><?phpget_footer();?>headermaincontentssidebarfooter
  • 46.
    index.php<?phpget_header();?> <?phpif ( have_posts()) : ?><?phpwhile (have_posts()) : the_post(); ?><?phpendwhile;?> <?phpelse :?> <?phpendif; ?><?phpget_sidebar(); ?><?phpget_footer();?>headermaincontentssidebarfooter
  • 47.
    index.php<?phpget_header();?> <?phpif ( have_posts()) : ?><?phpwhile (have_posts()) : the_post(); ?><?phpendwhile;?> <?phpelse :?> <?phpendif; ?><?phpget_sidebar(); ?><?phpget_footer();?>headermaincontentssidebarfooter
  • 48.
    index.php<?phpget_header();?> <?phpif ( have_posts()) : ?><?phpwhile (have_posts()) : the_post(); ?><?phpendwhile;?> <?phpelse :?> <?phpendif; ?><?phpget_sidebar(); ?><?phpget_footer();?>headermaincontentssidebarfooter
  • 49.
    index.php<?phpget_header();?> <?phpif ( have_posts()) : ?><?phpwhile (have_posts()) : the_post(); ?><?phpendwhile;?> <?phpelse :?> <?phpendif; ?><?phpget_sidebar(); ?><?phpget_footer();?>テンプレートタグWordPress組込の関数
  • 50.
    index.phpheader.php<?phpget_header();?> <?phpif ( have_posts()) : ?><?phpwhile (have_posts()) : the_post(); ?><?phpendwhile;?> <?phpelse :?> <?phpendif; ?><?phpget_sidebar(); ?><?phpget_footer();?>sidebar.phpfooter.php
  • 51.
  • 52.
  • 53.
  • 54.
    header.php<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" <?phplanguage_attributes(); ?>><head><meta http-equiv="Content-Type" content="<?phpbloginfo('html_type'); ?>; charset=<?phpbloginfo('charset'); ?>" /><title> <?phpwp_title('«', true, 'right'); ?> <?phpbloginfo('name'); ?></title><link rel="stylesheet" href="<?phpbloginfo('stylesheet_url'); ?>" type="text/css” /><style type="text/css”> #page { background: url("<?phpbloginfo('stylesheet_directory'); ?>/images/kubrickbg-ltr.jpg“) }</style><?phpwp_head(); ?></head><body><div id="page"><div id="header" role="banner"><div id="headerimg"><h1><a href="<?php echo get_option('home'); ?>/"><?phpbloginfo('name'); ?></a></h1><div class="description"><?phpbloginfo('description'); ?></div></div></div>
  • 55.
    header.php<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" <?phplanguage_attributes(); ?>><head><meta http-equiv="Content-Type" content="<?phpbloginfo('html_type'); ?>; charset=<?phpbloginfo('charset'); ?>" /><title> <?phpwp_title('«', true, 'right'); ?> <?phpbloginfo('name'); ?></title><link rel="stylesheet" href="<?phpbloginfo('stylesheet_url'); ?>" type="text/css” /><style type="text/css”> #page { background: url("<?phpbloginfo('stylesheet_directory'); ?>/images/kubrickbg-ltr.jpg“) }</style><?phpwp_head(); ?></head><body><div id="page"><div id="header" role="banner"><div id="headerimg"><h1><a href="<?php echo get_option('home'); ?>/"><?phpbloginfo('name'); ?></a></h1><div class="description"><?phpbloginfo('description'); ?></div></div></div>URLタイトルサイトの説明
  • 56.
  • 57.
    header.php<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" <?phplanguage_attributes(); ?>><head><meta http-equiv="Content-Type" content="<?phpbloginfo('html_type'); ?>; charset=<?phpbloginfo('charset'); ?>" /><title> <?phpwp_title('«', true, 'right'); ?> <?phpbloginfo('name'); ?></title><link rel="stylesheet" href="<?phpbloginfo('stylesheet_url'); ?>" type="text/css” /><style type="text/css”> #page { background: url("<?phpbloginfo('stylesheet_directory'); ?>/images/kubrickbg-ltr.jpg“) }</style><?phpwp_head(); ?></head><body><div id="page"><div id="header" role="banner"><div id="headerimg"><h1><a href="<?php echo get_option('home'); ?>/"><?phpbloginfo('name'); ?></a></h1><div class="description"><?phpbloginfo('description'); ?></div></div></div>
  • 58.
    header.php<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" <?phplanguage_attributes(); ?>><head><meta http-equiv="Content-Type" content="<?phpbloginfo('html_type'); ?>; charset=<?phpbloginfo('charset'); ?>" /><title> <?phpwp_title('«', true, 'right'); ?> <?phpbloginfo('name'); ?></title><link rel="stylesheet" href="<?phpbloginfo('stylesheet_url'); ?>" type="text/css” /><style type="text/css”> #page { background: url("<?phpbloginfo('stylesheet_directory'); ?>/images/kubrickbg-ltr.jpg“) }</style><?phpwp_head(); ?></head><body><div id="page"><div id="header" role="banner"><div id="headerimg"><h1><a href="<?php echo get_option('home'); ?>/"><?phpbloginfo('name'); ?></a></h1><div class="description"><?phpbloginfo('description'); ?></div></div></div>ドキュメントの場所は?
  • 59.
  • 60.
  • 61.
    index.phpWordPressループ(Main Contents)<?phpget_header();?> <?phpif (have_posts() ) : ?><?phpwhile (have_posts()) : the_post(); ?><?phpendwhile;?> <?phpelse :?> <?phpendif; ?><?phpget_sidebar(); ?><?phpget_footer();?>headermaincontentssidebarfooter
  • 62.
  • 63.
    WordPressループ<?phpif (have_posts()) :?><?phpwhile (have_posts()) : the_post(); ?><div <?phppost_class(); ?> id="post-<?phpthe_ID(); ?>"><h2><a href="<?phpthe_permalink()?>“ ><?phpthe_title(); ?></a></h2><small><?phpthe_time(__('F jS, Y', 'kubrick'))?></small><div class="entry"><?phpthe_content(__('Read the rest of this entry »', 'kubrick')); ?></div><p class="postmetadata"><?phpprintf(__('Posted in %s', 'kubrick'), get_the_category_list(', ')); ?> | <?phpedit_post_link(__('Edit', 'kubrick'), '', ' | '); ?> <?phpcomments_popup_link(__('No Comments »', 'kubrick'), __('1 Comment »', 'kubrick'), __('% Comments »', 'kubrick'), '',__('Comments Closed', 'kubrick') ); ?></p></div><?phpendwhile; ?><?phpelse : ?><h2 class="center"><?php _e('Not Found', 'kubrick'); ?></h2><p class="center"><?php _e('Sorry, but you are looking for something that isn’t here.', 'kubrick'); ?></p><?phpget_search_form(); ?><?phpendif; ?>
  • 64.
    <?phpif (have_posts()) :?><?phpwhile (have_posts()) : the_post(); ?><div <?phppost_class(); ?> id="post-<?phpthe_ID(); ?>"><h2><a href="<?phpthe_permalink()?>“ ><?phpthe_title(); ?></a></h2><small><?phpthe_time(__('F jS, Y', 'kubrick'))?></small><div class="entry"><?phpthe_content(__('Read the rest of this entry »', 'kubrick')); ?></div><p class="postmetadata"><?phpprintf(__('Posted in %s', 'kubrick'), get_the_category_list(', ')); ?> | <?phpedit_post_link(__('Edit', 'kubrick'), '', ' | '); ?> <?phpcomments_popup_link(__('No Comments »', 'kubrick'), __('1 Comment »', 'kubrick'), __('% Comments »', 'kubrick'), '',__('Comments Closed', 'kubrick') ); ?></p></div><?phpendwhile; ?><?phpelse : ?><h2 class="center"><?php _e('Not Found', 'kubrick'); ?></h2><p class="center"><?php _e('Sorry, but you are looking for something that isn’t here.', 'kubrick'); ?></p><?phpget_search_form(); ?><?phpendif; ?>投稿があればtrue、なければfalse投稿がある場合の処理投稿がない場合の処理
  • 65.
    <?phpif (have_posts()) :?><?phpwhile (have_posts()) : the_post(); ?><div <?phppost_class(); ?> id="post-<?phpthe_ID(); ?>"><h2><a href="<?phpthe_permalink()?>“ ><?phpthe_title(); ?></a></h2><small><?phpthe_time(__('F jS, Y', 'kubrick'))?></small><div class="entry"><?phpthe_content(__('Read the rest of this entry »', 'kubrick')); ?></div><p class="postmetadata"><?phpprintf(__('Posted in %s', 'kubrick'), get_the_category_list(', ')); ?> | <?phpedit_post_link(__('Edit', 'kubrick'), '', ' | '); ?> <?phpcomments_popup_link(__('No Comments »', 'kubrick'), __('1 Comment »', 'kubrick'), __('% Comments »', 'kubrick'), '',__('Comments Closed', 'kubrick') ); ?></p></div><?phpendwhile; ?><?phpelse : ?><h2 class="center"><?php _e('Not Found', 'kubrick'); ?></h2><p class="center"><?php _e('Sorry, but you are looking for something that isn’t here.', 'kubrick'); ?></p><?phpget_search_form(); ?><?phpendif; ?>投稿がある場合の処理
  • 66.
    <?phpif (have_posts()) :?><?phpwhile (have_posts()) : the_post(); ?><div <?phppost_class(); ?> id="post-<?phpthe_ID(); ?>"><h2><a href="<?phpthe_permalink()?>“ ><?phpthe_title(); ?></a></h2><small><?phpthe_time(__('F jS, Y', 'kubrick'))?></small><div class="entry"><?phpthe_content(__('Read the rest of this entry »', 'kubrick')); ?></div><p class="postmetadata"><?phpprintf(__('Posted in %s', 'kubrick'), get_the_category_list(', ')); ?> | <?phpedit_post_link(__('Edit', 'kubrick'), '', ' | '); ?> <?phpcomments_popup_link(__('No Comments »', 'kubrick'), __('1 Comment »', 'kubrick'), __('% Comments »', 'kubrick'), '',__('Comments Closed', 'kubrick') ); ?></p></div><?phpendwhile; ?><?phpelse : ?><h2 class="center"><?php _e('Not Found', 'kubrick'); ?></h2><p class="center"><?php _e('Sorry, but you are looking for something that isn’t here.', 'kubrick'); ?></p><?phpget_search_form(); ?><?phpendif; ?>投稿がある間Loopする投稿1つ分の準備投稿の数だけループ
  • 67.
    <?phpif (have_posts()) :?><?phpwhile (have_posts()) : the_post(); ?><div <?phppost_class(); ?> id="post-<?phpthe_ID(); ?>"><h2><a href="<?phpthe_permalink()?>“ ><?phpthe_title(); ?></a></h2><small><?phpthe_time(__('F jS, Y', 'kubrick'))?></small><div class="entry"><?phpthe_content(__('Read the rest of this entry »', 'kubrick')); ?></div><p class="postmetadata"><?phpprintf(__('Posted in %s', 'kubrick'), get_the_category_list(', ')); ?> | <?phpedit_post_link(__('Edit', 'kubrick'), '', ' | '); ?> <?phpcomments_popup_link(__('No Comments »', 'kubrick'), __('1 Comment »', 'kubrick'), __('% Comments »', 'kubrick'), '',__('Comments Closed', 'kubrick') ); ?></p></div><?phpendwhile; ?><?phpelse : ?><h2 class="center"><?php _e('Not Found', 'kubrick'); ?></h2><p class="center"><?php _e('Sorry, but you are looking for something that isn’t here.', 'kubrick'); ?></p><?phpget_search_form(); ?><?phpendif; ?>タイトル本文全部理解しないといけないの?
  • 68.
  • 69.
  • 70.
    ← not foundページ アーカイブページ コメントページ← 共通関数用← 画像一覧ページdefault 言語関連ファイル← リンクページ← 特定の1ページ← テーマのスクリーンショット← 検索ページ← 1投稿分の詳細ページ
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 79.
  • 80.
  • 81.
    <?php/*Template Name: XmlForFlash*/?><?phpheader('Content-Type: text/xml; charset='.get_option('blog_charset'), true); ?><?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.‘>’; ?><root><?phpquery_posts("posts_per_page=5"); ?><?phpif (have_posts()) : ?><?phpwhile (have_posts()) : the_post(); ?><item><title><![CDATA[<?php echo the_title_rss(); ?>]]></title><pubdate><?php echo the_time('Y-m-d H:i:s’); ?></pubdate><?phpthe_category_rss(); ?><description><![CDATA[<?phpthe_content_rss(); ?>]]></description></item><?phpendwhile; ?><?phpendif; ?></root><?xml version="1.0" encoding=“UTF-8” ?>タイトル時 刻<category></category>カテゴリ本文内容テンプレートタグで書くと?
  • 82.
    <?php/*Template Name: XmlForFlash*/?><?phpheader('Content-Type: text/xml; charset='.get_option('blog_charset'), true); ?><?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.‘>’; ?><root><?phpquery_posts("posts_per_page=5"); ?><?phpif (have_posts()) : ?><?phpwhile (have_posts()) : the_post(); ?><item><title><![CDATA[<?php echo the_title_rss(); ?>]]></title><pubdate><?php echo the_time('Y-m-d H:i:s’); ?></pubdate><?phpthe_category_rss(); ?><description><![CDATA[<?phpthe_content_rss(); ?>]]></description></item><?phpendwhile; ?><?phpendif; ?></root>続いてループ処理を挿入->
  • 83.
    <?php/*Template Name: XmlForFlash*/?><?phpheader('Content-Type: text/xml; charset='.get_option('blog_charset'), true); ?><?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.‘>’; ?><root><?phpquery_posts("posts_per_page=5"); ?><?phpif (have_posts()) : ?><?phpwhile (have_posts()) : the_post(); ?><item><title><![CDATA[<?php echo the_title_rss(); ?>]]></title><pubdate><?php echo the_time('Y-m-d H:i:s’); ?></pubdate><?phpthe_category_rss(); ?><description><![CDATA[<?phpthe_content_rss(); ?>]]></description></item><?phpendwhile; ?><?phpendif; ?></root>最新の5件を取得->
  • 84.
    <?php/*Template Name: XmlForFlash*/?><?phpheader('Content-Type: text/xml; charset='.get_option('blog_charset'), true); ?><?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.‘>’; ?><root><?phpquery_posts("posts_per_page=5"); ?><?phpif (have_posts()) : ?><?phpwhile (have_posts()) : the_post(); ?><item><title><![CDATA[<?php echo the_title_rss(); ?>]]></title><pubdate><?php echo the_time('Y-m-d H:i:s’); ?></pubdate><?phpthe_category_rss(); ?><description><![CDATA[<?phpthe_content_rss(); ?>]]></description></item><?phpendwhile; ?><?phpendif; ?></root>
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.