0

There are many posts that seem to strike around this area, but I'm more and more confused by each one I read.

I have a page that shows the "Terms of Service" (id = 1086). I would like to display the content of that page inside a template (signup.php) on another page.

I'm running latest version (4.3). I'm confused by where to put which bit of code. (functions.php vs right in the template etc...)

How can I show the content of my Terms of Service page on my signup template?

EDIT: Note the change to the post id.

Using @terminator's advice here is the code that I have on my signup.php page:

<div id="termsOfService">
  <?php $my_postid = 1086;//This is page id or post id
        $content_post = get_post($my_postid);
        $content = apply_filters('the_content', $content);
        $content = str_replace(']]>', ']]&gt;', $content);
        echo $content; ?>
</div> <!-- termsOfService -->

This returns an empty string

Here is the permalink and shortlink

enter image description here

1

It should work

<?php
$my_postid = 1772;//This is page id or post id
$content_post = get_post($my_postid);
$content = $content_post->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]&gt;', $content);
echo $content;
?>
|improve this answer|||||
  • This goes into the template file? Within a <?php tag? – paqogomez Aug 28 '15 at 22:50
  • yup this goes with in the <?php tag and in the template file – terminator Aug 29 '15 at 8:05
  • Could something be being stripped out here? I don't get anything to show up. I've verified the id by looking at the shortlink, but $content is blank. – paqogomez Aug 31 '15 at 14:34
  • @paqogomez why do you have $outout in get_post() – terminator Aug 31 '15 at 22:12
  • Oops, that was just something i tried based on the documentation of get_post(). I tried it both with and without. – paqogomez Sep 2 '15 at 16:31
0

The code that worked for me was the following:

<? $the_query = new WP_Query( 'page_id=1086' );
    while ( $the_query->have_posts() ) :
    $the_query->the_post();
    the_title();
    the_content();
    endwhile;
    wp_reset_postdata();
    ?>

I found this on a thread here

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.