I'm quite new to WordPress and wonder if there is a way to take the content in a normal page created in WP and show this content in a div tag through a page template?

The setup is two divs next to each other showing different content based on the two WP pages. When I change a page's content, the output in the corresponding div tag should change as well.


2 Answers 2


Assuming you have the following pages:

  1. Home
  2. About us that has a slug of about-us

And you want to display the content of the About us page into the Home page.

    $about_us = get_page_by_path('about-us'); // supply the page slug; i.e. about-us

    $about_us_content = get_the_content($about_us->ID);

<div><?php echo $about_us_content ; ?></div>

Alternatively, you can use the get_page_by_title to retrieve the post using its page title

  • Thanks, I`ll try this in the morning and get back to you!👍😎
    – Fredrik
    Commented Feb 14, 2018 at 21:14
  • Hello again, thank you for tip, I've tried but the only thing that shows is the contents from home, not the about us page. Because your code should be in the template. Must I add something to the functions file? Thank you in advance!!
    – Fredrik
    Commented Feb 16, 2018 at 10:30
  • The code snippet above should be on the right page template; i.e. home.php, or index.php. You can take a look at this Template Hierarchy for reference.
    – Den Isahac
    Commented Feb 16, 2018 at 12:08
  • <?php $klubbstadgar = get_page_by_title('klubbstadgar'); // supply the page slug; i.e. about-us $klubbstadgar_content = get_the_content($klubbstadgar->ID); ?> <div> <?php echo $klubbstadgar_content ; ?></div>, any thoughts?Now I have two templates, home and klubbstadgar (in swedish), in the left i have placed this code, i e home, with the intention to present the content in klubbstadgar in a div in the home page. the only thing that appears is the content of home!! so I am really a newbie this so I appreciate your help a lot!!! cheers
    – Fredrik
    Commented Feb 19, 2018 at 11:26
  • You should apply the_content before echoing it. "An important difference from the_content() is that get_the_content() does not pass the content through the 'the_content' filter. This means that get_the_content() will not auto-embed videos or expand shortcodes, among other things." Commented Mar 13, 2018 at 11:28

you can get page data by id.

$pagecontent = get_post('hereispageid'); 
echo $pagecontent ->post_content;
  • You should apply filters in there. Raw post_content shouldn't be printed (shortcodes, and so on). Commented Mar 13, 2018 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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