0
votes

Is there a way to include a processed page within another page?

E.g., in a template, we write $page_data = get_page( ... page ID here ... );

and we would like the page content AFTER its template has generated the content

So e.g., when we use

echo apply_filters('the_content', $page_data->post_content);

we only get the page content, we would like the whole page (wrapper, header, footer etc.)

1

1 Answers

0
votes

You might consider using an iframe:

<iframe src="http://example.com/page-B" style="border:none;width:100%;height:600px;"></iframe>

to display the whole page-B inside page-A.

You could also check out wp_remote_get() and wp_remote_retrieve_body() to fetch remote content:

$the_body = wp_remote_retrieve_body( wp_remote_get('http://example.com/page-B') );

The transients API gives you the possibility to cache the results for some $timetolive seconds, with:

set_transient( 'my_page_b', $the_body, $timetolive );

where you can fetch it with

get_transient( 'my_page_b' );

Resources:

http://codex.wordpress.org/HTTP_API

http://codex.wordpress.org/Function_API/wp_remote_get

http://codex.wordpress.org/Function_API/wp_remote_retrieve_body

http://codex.wordpress.org/Transients_API