WordPressでプラグイン内自作関数の有効範囲

このQ&Aのポイント
  • WordPressでプラグイン内の自作関数が呼び出せる有効範囲について調べています。プラグイン内で作成した関数をsingle.phpなどで呼び出すと正常に表示されますが、header.phpやfooter.phpなどではエラーが発生します。
  • サンプルのソースコードを使用してプラグインを作成しており、クラス内のメソッドを指定した場所では関数が呼び出せます。しかし、header.phpやfooter.phpなどではエラーが発生する理由がわかりません。
  • ShowTextクラス内で定義されたget_textメソッドによってテキストを表示することができます。プラグインの設定ページにおいて、テキストを設定することができ、header.phpなどでこのメソッドを呼び出すこともできますが、エラーが発生します。なぜでしょうか?
回答を見る
  • ベストアンサー

Wordpressでプラグイン内自作関数の有効範囲

Wordpressでプラグインの作り方を勉強しています。 http://tachibanacw.mond.jp/techwiki/index.php?WordPress%A5%D7%A5%E9%A5%B0%A5%A4%A5%F3%BA%EE%C0%AE このページの中段以降にあるclass ShowTextを作ってみているのですが、このページこう書いてあります。 ※ ただし、footer.phpやheader.php、sidebar.phpでは呼び出し方法(1)は使えない!!! この通りプラグイン内で作った関数を呼び出す <?php echo esc_html($showtext->get_text()); ?> をsingle.phpへ書き込むと正常に表示されますが header.phpやfooter.phpなどでは Call to a member function get_text() on a non-object in C:\xampp\htdocs\~ というエラーが出ます。(ローカルでテストしています) ↑のページには理由が書いてないのですが、これはなぜなのですか? サンプルのソースは以下です。 <?php /* Plugin Name: Show Text Plugin URI: http://localhost/wordpress/plugin Description: テキストを表示するだけのプラグイン Author: A.Hiruta Version: 0.1 Author URI: http://localhost/wordpress */ class ShowText { //「 __construct」はインスタンス化するときに実行されるメソッド function __construct(){ //クラス内のメソッドを指定する場合は第2引数は$thisを含めた配列になる add_action('admin_menu', array($this, 'add_pages')); } function add_pages(){ add_menu_page('テキスト設定','テキスト設定', 'level_8', __FILE__, array($this, 'show_text_option_page'), '', 26); } function show_text_option_page() { //$_POST['showtext_options'])があったら保存 if ( isset($_POST['showtext_options'])) { check_admin_referer('shoptions'); $opt = $_POST['showtext_options']; update_option('showtext_options', $opt); ?><div class="updated fade"><p><strong><?php _e('Options saved.'); ?></strong></p></div><?php } ?> <div class="wrap"> <div id="icon-options-general" class="icon32"><br /></div><h2>テキスト設定</h2> <form action="" method="post"> <?php wp_nonce_field('shoptions'); $opt = get_option('showtext_options'); $show_text = isset($opt['text']) ? $opt['text']: null; ?> <table class="form-table"> <tr valign="top"> <th scope="row"><label for="inputtext">テキスト</label></th> <td><input name="showtext_options[text]" type="text" id="inputtext" value="<?php echo $show_text ?>" class="regular-text" /></td> </tr> </table> <p class="submit"><input type="submit" name="Submit" class="button-primary" value="変更を保存" /></p> </form> <!-- /.wrap --></div> <?php } //何故かfooter.phpにはecho esc_html($showtext->get_text());を記述してもダメだった。 function get_text() { $opt = get_option('showtext_options'); return isset($opt['text']) ? $opt['text']: 'null desu.'; } } //クラスを記述して、その場でインスタンス化(実行) $showtext = new ShowText; ?> よろしくおねがいいたします。

  • PHP
  • 回答数1
  • ありがとう数10

質問者が選んだベストアンサー

  • ベストアンサー
回答No.1

関数の有効無効っていうより変数の有効無効 $showtextが定義されてないって状態です footer.phpやheader.phpは get_footer();やget_header();など 関数を使って呼び出されているので function.phpやindex.phpなどと名前空間が違います プラグインとfooter.php,header.phpに 「global $showtext;」 と書き足してやれば動くはずです あるいはheader.phpやfooter.phpを require(get_tamplate_directory().'/header.php'); っていうような読み込み方しても動くでしょう プラグインってのはやっつけて言えば function.phpへの追加コードです ただそれだけのものです あまり特別に考えることはありません

関連するQ&A

  • [wordpress] 固定ページで、カテゴリ名の

    [wordpress] 固定ページで、記事の一覧を表示し、その記事の属するカテゴリ名の表示 wordpressで、商品一覧ページを作成していて、一覧を表示するページは固定ページにしています。 その商品一覧の中で、記事(商品)の属するカテゴリ名を表示させたいのですが どうすればいいでしょうか? 商品が服なので、その商品が属するカテゴリを項目の一つとして出力したいのです。 つまり『抽出した商品毎(have_post()の出力結果)にカテゴリ名を抽出』という感じです。 具体的なソースも教えて頂けると助かります。 <?php the_category(); ?> はダメでした。 [参考ソース] <div id="collectionWrap" class="clearfix"> <?php $loop = new WP_Query( array( 'post_type' => 'collection', 'posts_per_page' => 8 ) ); while ( $loop->have_posts() ) : $loop->the_post(); ?> <div class="collection"> <div class="image"> <a href="<?php the_permalink() ?>"><?php echo wp_get_attachment_image(get_post_meta($post->ID,"画像",true),'medium' ); ?></a> </div> <div class="txt"> <div class="clearfix mb10"> <p class="upDate"><?php echo get_post_meta($post->ID,"性別",true); ?></p> <p class="seasons"> <span> /*ここにカテゴリの種類を出力 */ </span></p> </div> <p class="itemName"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></p> <p class="itemPrice">&yen;&nbsp;<?php echo get_post_meta($post->ID,"価格",true); ?></p> </div> </div> <?php endwhile; ?> <?php wp_reset_query(); ?> </div> どうかよろしく御願いします。足りない情報等あればおっしゃってください。 自分でもいろいろ調べてるのですが、わかりません。。急いでます。

    • ベストアンサー
    • PHP
  • Wordpressでのphp(投稿ナビを非表示に)

    WordpressでWebサイトを制作中です。 トップページに最新の投稿が表示できるようにしたのですが、その下に自動的に挿入されるページナンバー(次のページへの遷移)が動作しません。 (画像の、1,2,3、、、、13 のナンバーの部分です) 恐らく、Wordpressの「投稿」ページではなく、固定ページであるトップページにこの機能を組み込んだためかと思うのですが、特にページナンバーを表示させる必要がないため、ページナンバーだけを削除あるいは非表示にしたいのですが、phpの該当部分を削除すればいいのでしょうか? phpの知識がないために、お教えください。 Wordpressのファイル「page-home.php」の中に記述されてある中で、恐らく該当部分は以下かと思うのですが、この中で、どの部分を削除すればいいのでしょうか? 部分的に何度か削除してアップロードして試してみたのですが、不思議なことに、どの部分を削除しても、ページナンバーは消えません。 --------------------------------------------------- <!--LATEST POSTS--> <?php if(of_get_option('latstpst_checkbox') == "1"){ ?> <?php $args = array( 'post_type' => 'post', 'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1)); query_posts($args); ?> <?php get_template_part(''.$zn_lays = of_get_option('layout_images', 'layout1').''); ?> <?php } else { ?> <?php } ?> <!--LATEST POSTS END--> -------------------------------------------------------- ちなみに、Wordpressは最新のバージョン 4.9.5–ja、 テンプレートの「Ttheron_lite」を利用しています。 情報として不足部分がありましたら、申し訳ありません。 ご指摘くださいましたら、情報を追加いたします。 なお、ブラウザに表示後にHTMLソースから、ナンバー部分に相当しそうな 部分のクラスに対して、 display: none; をstyle.cssに記述することも試してみたのですが、 やはり表示は消えません。 参考:http://evm-label.com/2015/05/wp_postnavi_hide01/ HTMLソースでは、この部分のようです。 <div class="thn_paginate"><span class='amp_title'>Pages:</span><a href='...../wp/' class='amp_page amp_current'>1</a><a href='...../wp/page/2/' class='amp_page'>2</a><a href='...../wp/page/3/' class='amp_page'>3</a><a href='...../wp/page/4/' class='amp_page'>4</a><a href='...../wp/page/5/' class='amp_page'>5</a><a href='...../wp/page/6/' class='amp_page'>6</a><a href='...../wp/page/7/' class='amp_page'>7</a><span class='amp_gap'>...</span><a href='...../wp/page/13/' class='amp_page'>13</a><a href='...../wp/page/2/' class='amp_next'>&raquo;</a></div> <div class="hidden_nav"></div> リンクのURL部分は、サイト公開前のために、伏せています(問題ありますでしょうか?) よろしくお願いいたします。

    • 締切済み
    • PHP
  • Wordpressで特定カテゴリーの一覧ページ

    今特定のカテゴリーの一覧ページを作りたいのですがうまく作れません。 http://snapkidz.biz/wp/?cat=4(現状) 本当はhttp://blackartcard.com/?cat=4のような感じで作りたいんですがうまくいきません。 二つとも自分のサイトなのですが、http://blackartcard.com/?cat=4の方はテンプレートをいじって作ったので、うまくいっただけです。 アーカイブ.phpを同じ物をsnapkidz.bizにいれたのですがレイアウトがヘッダー部分に表示されるようになってしました。 アーカイブの中身は以下です。 <?php /** * @package WordPress * @subpackage Modularity */ ?> <?php get_header();?> <div> <?php query_posts($query_string.'&posts_per_page=2'); if (have_posts()) : ?> <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?> <div class="clear"></div> <div class="content"> <?php while (have_posts()) : the_post(); ?> <div class="archive-top"> <?php the_post_thumbnail('full'); ?> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf( esc_attr__( 'Permalink to %s', 'modularity' ), the_title_attribute( 'echo=0' ) ); ?>"><?php the_title() ?></a></h2> <div class="clear"></div> <p class="postmetadata alt quiet"> <?php $tag_list = get_the_tag_list( '| Tags: ', ', ' ); printf( __( '%1$s | Categories: %2$s %3$s | ', 'modularity' ), get_the_time( get_option( 'date_format' ) ), get_the_category_list( ', ' ), $tag_list ); ?> </p> <hr /> </div> <?php endwhile; ?> <div class="clear"></div> <div class="navigation"> <div class="alignleft"><?php next_posts_link( __( '&laquo; 前の記事', 'modularity' ) ); ?></div> <div class="alignright"><?php previous_posts_link( __( '次の記事 &raquo;', 'modularity' ) ) ?></div> </div> <div class="clear"></div> <?php else : ?> <h2 class="center"><?php _e( 'Not Found', 'modularity' ); ?></h2> <?php get_search_form(); ?> <?php endif; ?> </div> </div> </div> <!-- Begin Footer --> <?php get_footer(); ?> どうすればヘッダー下にうまく表示できるでしょうか?? 宜しくお願い致します。

    • 締切済み
    • CSS
  • ajaxを使用してckeditorを表示したい

    PHPとjquery1.3 で ajax を使用し、下記のような処理を書いてみました。 text.phpにckeditorを表示させたいのですが、どのようにすればいいのでしょうか? ソースコードで教えて頂けると助かります! ちなみに呼び出しもとのファイルでの ckeditor の動作は確認できました。 よろしくお願いします。 ■呼び出し元のhtml <html> <head> <script type="text/javascript" src="jquery-1.3.2.min.js"></script> <script type="text/javascript" src="ckeditor/ckeditor.js"></script> <script type="text/javascript"> $( function() { $("select").change(function () { var value = ""; $("select option:selected").each(function () { value += $(this).val(); }); $("#out").load("text.php?name=" + value); }).change(); }); </script> <title>テスト</title> </head> <body> <select name="text"> <option value="normal">テキスト入力</option> <option value="html">htmlエディター</option> </select> <div id="out"></div> </body> </html> ■text.phpの内容 <? if(isset($_GET['name'])){ $name = $_GET['name'];} if($name == "normal"){ ?><textarea cols="80" rows="10">テキスト入力</textarea><? }elseif($name == "html"){ ?><textarea class="ckeditor" id="editor" cols="80" rows="10">htmlエディター</textarea><? } ?>

  • WordPress 条件分岐間違っている箇所は?

    WordPressで最新記事を判別して大きく見せるなど、表示を変更する条件分岐のカスタマイズ方法を下記のURLを参考に改造しました。 https://whitebear-seo.com/wordpress-newpost-conditional-branch/ 結果はエラーが出ました。 どこが間違っているか教えていただけないでしょうか? 宜しくお願いします。 <?php if ( have_posts() ) : if ( is_home() && ! is_front_page() ) : ?> <?php endif; /* 改造前 */ while ( have_posts() ) : the_post(); /* 改造前 */ get_template_part( 'template-parts/content', get_post_format() ); /* ページネーション */ endwhile; echo '<div class="text-center paging-navs">'; the_posts_pagination(); echo '</div>'; else : get_template_part( 'template-parts/content', 'none' ); /* ページネーション END */ endif; ?> /* 改造後 */の部分だけ改造しました。 ↓ <?php if ( have_posts() ) : if ( is_home() && ! is_front_page() ) : ?> <?php endif; /* 改造後 */ while ( have_posts() ) : the_post(); $counter++; if ($counter <= 1): ? get_template_part( 'template-parts/content2', get_post_format() ); else: /* 改造後 */ get_template_part( 'template-parts/content', get_post_format() ); /* ページネーション */ endwhile; echo '<div class="text-center paging-navs">'; the_posts_pagination(); echo '</div>'; else : get_template_part( 'template-parts/content', 'none' ); /* ページネーション END */ endif; ?>

    • 締切済み
    • PHP
  • wordpressで

    wordpressを使ってブログを作っています。しかしcssを読み込んでくれません。 index.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"> <head> <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" /> <title><?php bloginfo('name'); ?><?php wp_title(': '); ?></title> <meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats please --> <link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?>(RSS 2.0)" href="<?php bloginfo('rss2_url'); ?>" /> <link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?>(Atom)" href="<?php bloginfo('atom_url'); ?>" /> <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" /> </head> <body> <div id="rap"> <div id="header"> <div id="headerimg"> <h1><a href="<?php echo get_settings('home'); ?>/"><img src="img/title.gif" alt="芦澤治療院はやさしいマッサージで施術いたします。" /></a></h1> </div> <div id="headernavi"> <div id="navi"> <ul> <li><a href="#"><img src="img/link.gif" alt="" border="0" /></a></li> <li><a href="#"><img src="img/sitemap.gif" alt="" border="0" /></a></li> <li><a href="#"><img src="img/inquary.gif" alt="" border="0" /></a></li> </ul></div> <div id="size"> <img src="img/sizeword.gif" alt="" /> <a href="#"><img src="img/sizesmall.gif" alt="" border="0" /></a> <a href="#"><img src="img/sizemiddle.gif" alt="" border="0" /></a> <a href="#"><img src="img/sizebig.gif" alt="" border="0" /></a></div> </div> </div> <div id="navcontainer"> <ul> <li class="news"><a href="#">ニュース</a></li> <li class="cut"><img src="img/linecut.gif" alt="" /></li> <li class="work"><a href="#">施術の案内</a></li> <li class="cut"><img src="img/linecut.gif" alt="" /></li> <li class="stuff"><a href="#">スタッフ</a></li> <li class="cut"><img src="img/linecut.gif" alt="" /></li> <li class="qa"><a href="#">よくある質問</a></li> <li class="cut"><img src="img/linecut.gif" alt="" /></li> <li class="inq"><a href="#">お問い合わせ</a></li> </ul> </div> <!-- end header --> <div id="content"> <div id="main"> <?php if(have_posts()):while(have_posts()):the_post();?> <div class="post"> <h2><?php the_title();?></h2> <?php the_content();?> <p class="postmetadate"> <?php the_time('Y年m月d日 H:i')?>|<?php comments_popup_link ('コメント(1)','コメント(2)','コメント(%)');?> </p> </div> <?php comments_template();?> <?php endwhile;endif;?> </div> </div> </div> </body> </html> です。 ディレクトリ構造はindex.htmlとstyle.cssは同じフォルダにあります。

    • 締切済み
    • PHP
  • WordPressの各ページにh1を作りたい

    ここ数日、行き詰まっています。どうしても解決ができなく、 ご教示頂けませんでしょうか。 何卒よろしくお願い申し上げます。 現在、WordPressテーマのヘッダーphpに条件分岐でH1をつけようと取り組んでいます。 今できていることは、 ・トップページのh1表示 ・投稿、固定ページにカスタムフィールドにh1を作り、それぞれのページに表示 ・カテゴリー、タグの一覧ページへの表示 ・お知らせの一覧と詳細ページへの表示 できていないこと ・通常の投稿のアーカイブページへの表示 ・製品カテゴリーで設定した名前での一覧ページ(アーカイブ)への表示 となります。 もともとのテンプレートには、製品紹介用のカスタム投稿タイプが用意されていました。 管理画面上のメニューでは、 製品紹介 -新規追加 -製品カテゴリー となっています。 できていないというのは、この製品カテゴリーのところになり、 WordPress Codexの条件分岐タグページを見ながらいろいろ組み替えたり したのですが、どうしてもうまく表示することができないでおります。 ソースは以下のようにしています。 <?php if(is_front_page() && is_home()): ?> <div class="area-h1"> <h1>トップページのh1は表示されています。</h1> </div> <?php elseif(is_category()): ?> <div class="area-h1"> <h1>カテゴリー:<?php single_cat_title(); ?>で表示されています。</h1> </div> <?php elseif(is_tag()): ?> <div class="area-h1"> <h1>タグ:<?php single_tag_title(); ?> で表示されています。</h1> </div> <?php elseif(is_post_type_archive( 'news')): ?> <div class="area-h1"> <h1>お知らせ一覧に表示されています。</h1> </div> <?php elseif(is_singular( 'news')): ?> <div class="area-h1"> <h1><?php the_time('Y'); ?>年<?php the_time('M'); ?><?php the_time('d'); ?>日のお知らせで表示されています。</h1> </div> <?php elseif(is_post_type_archive( 'product')):?> <div class="area-h1"> <h1>商品一覧に表示されました。</h1> </div> <?php elseif(is_singular( 'product')): ?> <div class="area-h1"> <h1><?php echo get_post_meta($post->ID , 'h1' ,true); ?>で商品ページに表示されました。</h1> </div> ※ここから下が分かりません。 <?php elseif(is_archive()): ?> <div class="area-h1"> <h1><?php the_time('Y'); ?>年<?php the_time('M'); ?>の記事一覧、通常投稿のアーカイブページ</h1> </div> ↑ どちらか一方しか有効でない ↓ <?php elseif(is_archive( 'product')): ?> <div class="area-h1"> <h1><?php single_cat_title(); ?>製品カテゴリー毎のアーカイブページ?</h1>   </div> <?php endif ; ?> その他に試したもの (1)<?php elseif(is_tax( 'product')): ?> <div class="area-h1"> <h1><?php single_cat_title(); ?>製品カテゴリー毎のアーカイブページ?</h1> </div> (2)<?php elseif(is_category( 'product')): ?> <div class="area-h1"> <h1><?php single_cat_title(); ?>製品カテゴリー毎のアーカイブページ?</h1> </div> ここ数日、ずっとできないでおりまして、 おかしなところなどアドバイスを頂けましたら本当に助かります。 何卒よろしくお願い申し上げます。

    • 締切済み
    • PHP
  • wordpress 検索フォームと結果を同ページで

    wordpressで検索フォームと検索結果を作成しています。 検索フォームは <form action="<?php echo home_url(); ?>" method="get"> <dl> <dt> お部屋のタイプ</dt> <dd> <?php wp_dropdown_categories(array( 'show_option_all' => '全てのタイプ' )); ?></dd> <dt> こだわり検索</dt> <dd> <?php $terms = get_terms('good'); foreach ($terms as $term): ?> <label> <input type="radio" name="good" value="<?php echo esc_attr($term->slug); ?>"> <?php echo esc_html($term->name); ?></label> <?php endforeach; ?> </select> </dd> <dt> キーワード</dt> <dd> <input type="text" value="" name="s" /> </dd> </dl> <input type="submit" value="この内容で検索!" /> </form> としています。 検索結果は「search.php」を作り <div id="wrapper"> <h4 class="h4_search">★検索結果</h4> <div id="content"> <section> <?php if (is_search()) : ?> <?php endif; ?> <?php if (have_posts()) :?> <div class="postWrap"> <?php while (have_posts()) : the_post(); ?> <article id="post-<?php the_ID(); ?>"> <div class="search"> <header> <h5><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><span><?php the_title(); ?></span></a></h5> <a href="<?php the_permalink(); ?>"> <?php the_post_thumbnail(); ?></a> <?php echo mb_substr(get_the_excerpt(),0, 50);?> <a href="<?php the_permalink();?>">&emsp;…&nbsp;続きを読む</a> </header> </div> <?php endwhile; ?> </div> <?php endif; ?> としています。 このままでは、検索フォームのあるページから別のページ(search.php)に飛んで検索結果が出ます。 ここで、検索結果を検索フォームのあるページ内で表示したいと思っております。 検索フォームに入力し、submitボタンを押すと、そのすぐ下に検索結果がずらりと表示できるようにしたいです。 このようなことは可能でしょうか? できればプラグインを使わずに実現したいので、コードを教えていただければ有難いです。 何卒よろしくお願いします。

    • ベストアンサー
    • PHP
  • wordpress キャプションが<p>として吐き出される

    Limit Posts jaというプラグインを入れ、topページに記事(200文字まで)一覧を表示しています。 (PHPソース) <div class="box clearfix"> <?php echo tb_post_thumb(true);?> <div class="cts-list"><?php the_content_limit(200, "続きを見る"); ?></div> </div> これで投稿記事の画像と文章(200文字まで)を取得しているのですが、 画像のキャプションが文章として吐き出されているのです。 投稿記事のページでは、ちゃんとキャプションとして扱われているのですが。。 (HTMLソース) <div class="box clearfix"> <img src="http://www." width="90" height="90" alt="" /> <div class="cts-list"> <p>キャプションここに文章が入ります...<a href='http://www.//省略/?p=87'>続きを見る</a></p> </div> </div> キャプションが平然とした顔で<p>タグに囲まれてます......泣 なんとか一覧ページでキャプションが文章としてではなく、キャプションとして認識させれないでしょうか? なんでもいいです。 文章とは別物として扱えるようになれば。。 記事のページのHTMLソースも載せておきます。 <div class="box clearfix"> <div id="attachment_88" class="wp-caption aligncenter" style="width: 345px"> <img class="size-medium wp-image-88" title="ピクチャ 3" src="http://www" alt="ピクチャ 3" width="335" height="212" /> <p class="wp-caption-text">キャプション</p></div> <p style="text-align: center;"><p>ここに文章が入ります</p> </div> 宜しくお願いしますっ!!!!困ってます!!!すみません!!

    • 締切済み
    • PHP
  • DreamweaverとWordPressの連携

    Xamppを使用してローカルサーバーにWordpressをインストールしました。 DreamweaverとWordpressを連携させてサイト作りをしようと思っています。 ソシム社の「WordPressレッスンブック」という本を読みながら勉強をしているのですが、Dreamweaver(CS5)上からファイルのパーミッションの変更ができません。 何度試みて更新してみてもパーミッションは0のままです。 FFFTPソフトを使わないと出来ないのでしょうか? またFFFTPソフトからホストに接続しようとすると、Xamppに適したユーザー名やパスワードが見つからず接続できません。 xamppディレクトリ制御、Mysql、ベーシック認証のいずれのパスワードを入力しても接続できません。 こちらのサイトも参考にしましたが分かりませんでした。(http://d.hatena.ne.jp/k3akinori/20100118/1263780463) wp-includesの中にあるindex.phpをdreamweaverのライブビューで見るところまでは成功しましたが、「WordPressレッスンブック」のやり方で作ったindex.phpは全く反映されず真っ白なままです。 index.phpとcssどちらも本に付属していたCDから正式なソースを抜き取って記述してみましたが、全く変わりません。 Wordpressの本サーバーで同じ事を試みるとほぼ問題はありませんが、効率化を図るためにローカルサーバーでサイト作りを試みたいと思っております。 ヒントでもよいので、何か教えていただければ幸いです。 index.php記述(「WordPressレッスンブック付属CDの記述)」 <!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"> <head> <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>;charset=<?php bloginfo ('charset'); ?>" /> <title><?php bloginfo('name'); ?><?php wp_title(); ?></title> <link rel="stylesheet" href="<?php bloginfo ('stylesheet_url'); ?>" type="text/css" /> </head> <body> <!-- コンテナ --> <div id="container"> <!-- ヘッダー --> <div id="header"> <h1><a href="<?php echo home_url(); ?>"> <?php bloginfo('name'); ?></a></h1> <p id="desc"><?php bloginfo('description'); ?></p> <p id="image"><img src="<?php bloginfo('template_url'); ?>/header.jpg" alt="*" width="760" height="200" /></p> </div> <!-- コンテンツ --> <div id="content"> <?php if(have_posts()): while(have_posts()): the_post(); ?> <div class="post"> <h2><a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a></h2> <?php the_content(); ?> <p class="postinfo"> <?php echo get_the_date(); ?> <?php the_time(); ?> | カテゴリー:<?php the_category(', '); ?> </p> </div> <?php if(is_single()): ?> <p class="pagelink"> <span class="oldpage"><?php previous_post_link(); ?></span> <span class="newpage"><?php next_post_link(); ?> </span> </p> <?php endif; ?> <?php endwhile; endif; ?> <?php if(is_home()): ?> <p class="pagelink"> <span class="oldpage"><?php next_posts_link('&laquo; 古い記事'); ?></span> <span class="newpage"><?php previous_posts_link('新しい記事 &raquo;'); ?></span> </p> <?php endif; ?> </div> <!-- フッター --> <div id="footer"> <address>Copyright &copy; <a href="mailto:<?php bloginfo('admin_email'); ?>">Hidamari Diary</a>, All rights reserved.</address> </div> </div> </body> </html> style.cssもコピー&ペーストして「Wordpressレッスンブック」と同じ記述になっています。

専門家に質問してみよう