Display All Pages On One Page In Wordpress?

Hi.

I’m trying to create a one page (parallax scrolling, single page display) wordpress site.

Naturally, part of this is displaying all pages as one.

However, I’m not sure how to do that and there are (surprisingly) no good tutorials for it online.

I’ve checked Stack Overflow and they do have some questions regarding this subject. People usually respond with a PHP script; however, they never say which document the PHP has to be inserted in.

Here’s an example:

http://stackoverflow.com/questions/7023310/wordpress-display-all-pages-on-one-page

They just say “use this script.” But where do you insert it?

It’ll depend on your theme. Regardless:

  • First, make sure to set your home page as the actual home page in the dashboard: Settings > Reading > Page on Front
  • Next, open up one of the following (go in order, if your theme doesn’t have the first one, check the next one etc. This is important!). Just in case, these files will be located in /wp-content/themes/YOURTHEME/
    • front-page.php
    • page.php
    • index.php
  • Next copy+paste the snippet in that link into your the script from above. Where depends on your theme, just stick it anywhere after the <?php get_header() ?> for now (I don’t know what your script looks like, so I can’t help you there).
  • If you literally see what you copy pasted, surround it with <?php [...] ?>, if you get an error surround it with ?> [...] <?php

That’s as good as I can help you without actually seeing any code. As to making it “parallax” (I think you really mean “infinitely scrollable”) that’s a whole nother story.

I’d create two pages, “Home” and “Blog”. Under settings > reading I would set the home page to home and the blog page to blog.

Then add all the content for the one page scroller to the home page. Having said that, I wouldn’t just paste all the HTML and stuff into the page. (though you could) Rather, I would organize my front-page.php file (as mentioned above) to structure the page, then pull content from the database.

Or: https://wordpress.org/plugins/improved-include-page/

To display all page contents in a single page, you can use the following code. It also helps to get the page title to display in a single page.

<?php 
$pages = get_pages(); 
foreach ($pages as $page_data) {
     $content = apply_filters(‘the_content’, $page_data->post_content); 
     $title = $page_data->post_title; 
     echo $content; 
}
?>

To display a page content in another page:

<?php 
$page_id = <your page id, from where you want to grab content>; 
$page_data = get_page( $page_id ); 
$content = apply_filters(‘the_content’, $page_data->post_content); 
$title = $page_data->post_title; 
echo $content; 
?>

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.