感謝手伝い。
私が言ったように、私はsite.com/blog
にWordpressをインストールしました。そして、私はsite.comのホームページ(index.php
)に、ページの "News"セクションに3つのWordpress投稿を表示したかったのです。
だから、私は追加する必要がありましたsite.comのために:
<div id="news">
<p>Here you can see our latest News</p>
<?php
define('WP_USE_THEMES', false);
require('blog/wp-blog-header.php'); //Note the folder hierarchy to find wp-blog-header.php
?>
<?php
$my_query = new WP_Query('showposts=3'); //"3" being the number of posts to be shown
while ($my_query->have_posts()): $my_query->the_post();
?>
<h3><?php the_title() ?></h3> //This makes the post title show inside a h3 tag
<p><?php the_excerpt() ?></p> //This makes the post excerpt show inside a p tag
<?php endwhile;
?>
</div>
あなたは他のウェブサイト – Marcin
からデータを取得するためにjQueryのAJAXを使用することができますが、すべての記事を表示しますか? –
Marcin、私はWordPressに独自のPHP関数があることを知っていますので、jQueryの使用を避けたいと思います。 ChemistryBlob、いいえ、ちょっと最近のもの!私は配列を使用する必要がありますよね?同様に、3は良いスタートになるでしょう。 –