WordPress以外のサイトでWordPressのタグを使う方法
【サーバー別】HTML上でPHPを実行するための.htaccessの記述
Studio Zeroのニュース3件をwordpressで作成した記事の新着3件を自動で
表示したいと思います。
(1)index.htmlをindex.phpと書き換えます。
1行目に
<?php require(‘./blog/wp-load.php’); ?>
と記述します。
(2)表示ループを書きます。
———————————————————————
[html] <?php query_posts(‘post_type=news’); ?><?php if(have_posts()): while(have_posts()): the_post(); ?>
<div class=”post”>
<dl id=”news”>
<div class=”post-header”>
<dt><div class=”post-meta”><span class=”icon-clock”><?php echo get_the_date(); ?></span><span class=”icon-folder”><?php the_category(‘,’); ?></span><span class=”icon-tags”><?php the_tags(‘,’); ?></span></div></dt>
</div><!–post-header–>
<dd><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></dd>
</dl>
</div><!–post–>
<?php
endwhile;
?>
<?php
endif;
?>[/html]
————————————————————-
index.phpになってもURLは変わらないので、おすすめです。
他にもRSSを取得して表示する方法もあるようです。