0

私はWordpressで構築しており、jQuery.loadを使用してロードするコンテンツがいくつかあります.

$item = '<h2>'. the_title() .'</h2><div>'. the_content() .'</div>';
//$item = include 'myrequire.php'; This doesn't seem to work. 

php 変数 $item に php ファイルをロードする方法を知りたいので、functions.php を整頓して、次のようにファイルを書くことができます。

<h2><?php the_title(); ?><h2> 

... それは理にかなっていますか?

ありがとう!

このチュートリアルに従いました: http://tomsbigbox.com/wordpress-load-more-posts-on-page-scroll/

完全なスニペットは次のとおりです。

function getArchives($count,$offset){
query_posts('posts_per_page='.$count.'&offset='.$offset);

$posts = array();

if(have_posts()) : while(have_posts()) : the_post();    


    $item = '<h2>'. the_title() .'</h2><div>'. the_content() .'</div>';
    //$item = include 'myrequire.php';

array_push($posts,$item); endwhile; endif;

return $posts;
};
4

2 に答える 2

1

http://www.php.net/manual/en/function.file-get-contents.php

PHPファイルの内容を知りたいですか?

于 2013-03-30T19:57:01.157 に答える
0

include はファイルを実行します。必要な file_get_contents

$var=file_get_contents($filename);

get_template_part を使用してワードプレスの方法で行うこともできますが、それは何をしたいかによって異なります。私はコーデックスhttp://codex.wordpress.org/Function_Reference/get_template_partを見ます

于 2013-03-30T19:56:11.680 に答える