既存のサイト:静的HTML( hoge.com/blog.html )にwordpressを部分的に埋め込む方法を教えていただけませんでしょうか。最初からwordpressで作りなよという回答はご遠慮ください。
調べた限り、私のイメージでは
「wordpressをサーバーにある自社のHPのドメインのルートディレクトリに導入後、html自体ではphpを実行できないので.htaccessを修正することでblog.html 内でphpを実行→WPのタグ(テンプレートタグ?)を実行することで表示させる」
なのですが、いかがでしょうか。
【参考にしたサイト】
http://w3q.jp/t/6638
http://www.webopixel.net/wordpress/206.html
http://webaffi.net/wordp/wp-inputhtml/
http://mypacecreator.net/blog/archives/983
みんなの回答 10 件
導入イメージはこの画像のような構造をイメージしています。
さらに細かく言うと、この画像でいうところのheader.phpとfooter.php以外の部分をblog.html内で表示させたいですが・・・・・・。
よろしくお願いいたします。
Google Feed APIは?
画像が小さすぎて何のこっちゃらだが、WPは普通にどっかに構築しといて、それをAjaxで読み込んだ方が早いかもね。
参考にしたサイトに書いてるじゃん。
Codexに載ってるけど、
> WPのタグ(テンプレートタグ?)を実行することで表示させる
の前にwp-blog-header.phpを読み込ませるだけ。
require(’/the/path/to/your/wp-blog-header.php’);
出来れば普通に.phpで作った方がいいと思うけど。
Integrating WordPress with Your Website « WordPress Codex
http://codex.wordpress.org/Integrating_WordPress_with_Your_Website「.htaccessを修正」でできますよ。サーバーが禁止していなければ。
index.phpは削除して、index.htmlにheader.phpとfooter.phpを、<?php include("phpファイルのディレクトリを指定");?>を記入してインクルードさせる。・・・参考サイトと同じですね。
blog.htmlにしないでblogっていうディレクトリをつくってそこにワードプレスをインストールしたらいいと思うけど。これだと難しく考えなくてインストールは通常と同じで簡単だよ。
以下の手順で改変を加えてみましたが、うまくいきませんでした。
どこがダメなのでしょうか……
ちなみにWPはインストール後デフォルトのままです。
【hogehoge.comの階層(修正前)】
index.html
hoge.html
img
-hoge.jpg
-hoge.jpg
components
-css
-img
blog(この中にWPインストールしました)
-.htaccess
-index.php
-wp-blog-header.php
-その他
-wp-admin
-その他
【修正箇所&手順】
1)index.htmlの1行目に
<?php require(’./blog/wp-blog-header.php’); ?> を挿入
2)index.htmlと同じ階層に
AddHandler php5.3-script .html .htm
と1行だけ書かれた.htaccessを設置。(サーバーがロリポップ)
3)index.htmlの適当な行に
<?php
define(’WP_USE_THEMES’, true);
require(’./blog/wp-blog-header.php’);
?>
と挿入。→変化なしのため削除
4)index.htmlの適当な行に
<?php
query_posts(’&posts_per_page=7’);
if (have_posts()) : while (have_posts()) : the_post();
?>
<?php get_template_part(’loop-home’); ?>
<?php endwhile; endif; ?>
と挿入→変化なしのため削除。loop-homeという別のphpファイルを別途用意しなければ反応しない?
5) index.htmlの適当な行に別の記述をしてみる
<?php
$posts = get_posts(’numberposts=50&category=3’);//カテゴリと表示件数指定
global $post;
if($posts): foreach($posts as $post): setup_postdata($post); ?>
<dl>
<dt><?php the_time(__(’Y/n/j’)) ?></dt>
<dd><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></dd>
</dl>
<?php endforeach; endif;?>
→変化なしのため削除。
すいません。上記の書き込みも【トピ主】です。
---続き---
6) index.htmlの適当な行に別の記述をしてみる
<?php include("index.php"); ?>
→変化なしのため削除。
7) index.htmlの適当な行に別の記述をしてみる
<?php include("blog/index.php"); ?>
→変化なしのため削除。
8) index.htmlの適当な行に別の記述をしてみる
<?php include("/blog/index.php"); ?>
→エラーのため削除
Warning: include(/blog/index.php) [function.include]: failed to open stream: No such file or directory in /home/users/1/lolipop.jp-ほhogehoge/web/index.html on line 54
Warning: include() [function.include]: Failed opening ’/blog/index.php’ for inclusion (include_path=’.:/usr/local/php5.3/php’) in /home/users/1/lolipop.jp-hogehoge/web/index.html on line 54
9) index.htmlの適当な行に別の記述をしてみる
<?php include("./blog/index.php"); ?>
→変化なしのため削除。
10) index.htmlの適当な行に別の記述をしてみる
<?php include("../blog/index.php"); ?>
→エラーのため削除
Warning: include(../blog/index.php) [function.include]: failed to open stream: No such file or directory in /home/users/1/lolipop.jp-hogehoge/web/index.html on line 54
Warning: include(../blog/index.php) [function.include]: failed to open stream: No such file or directory in /home/users/1/lolipop.jp-hogehoge/web/index.html on line 54
Warning: include() [function.include]: Failed opening ’../blog/index.php’ for inclusion (include_path=’.:/usr/local/php5.3/php’) in /home/users/1/lolipop.jp-hogehoge/web/index.html on line 54
11) index.htmlの適当な行に別の記述をしてみる
<?php include_once("index.php"); ?>
→エラーのため削除
Warning: include_once(index.php) [function.include-once]: failed to open stream: No such file or directory in /home/users/1/lolipop.jp-hogehoge/web/index.html on line 54
Warning: include_once() [function.include]: Failed opening ’index.php’ for inclusion (include_path=’.:/usr/local/php5.3/php’) in /home/users/1/lolipop.jp-hogehoge/web/index.html on line 54
12)再度6)と記述してみる
→エラーのため削除
Warning: include(index.php) [function.include]: failed to open stream: No such file or directory in /home/users/1/lolipop.jp-hogehoge/web/index.html on line 54
Warning: include(index.php) [function.include]: failed to open stream: No such file or directory in /home/users/1/lolipop.jp-hogehoge/web/index.html on line 54
Warning: include() [function.include]: Failed opening ’index.php’ for inclusion (include_path=’.:/usr/local/php5.3/php’) in /home/users/1/lolipop.jp-hogehoge/web/index.html on line 54
13)再度7)と記述
→エラーなしだが、変化なしのため削除
14)再度6)と記述してみる
→エラーのため削除。
15)index.htmlの適当な行に別の記述をしてみる
上記のindex.phpをwp-blog-header.phpにしてみる
→変化なしのため削除。
関連するトピックス