The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other How to display pages (not posts) in wordpress?

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #191292

    I want to know how I can display a page created in wordpress on the front end. I don’t want to display the ‘post’, I want to display the ‘page’ e.g ‘about us’ page.


        while(have_posts()) : the_post(); ?&gt;
                &lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;
                &lt;?php the_content(''); ?&gt;
    &lt;?php endwhile; wp_reset_query(); ?&gt;

    It’s not clear what you want exactly.

    A Post can be shown as an individual, or you can show a number of posts on one page.
    A Page can only be shown individually (e.g.

    So what are you trying to do exactly? You want to show the contents of a Page on a page where there’s normally a Post?


    Hi, yes you’re right, I want to show contents of a page on a page where there is nornally a list of posts. In the same way I wish to loop through all of my pages and display every single page on that main front page.

    I hope that makes sense?




    If you need to pull page content you need to use WP_Query and ask for that specific data. To go with @Senff example above, if you had a page with a slug of about-us your code would look like this:

    // You can also use page ID as 'page_id' => '11'
    // instead of 'pagename' => 'about-us', 11 would be the unique page ID.
    $query_arguments = array('pagename' => 'about-us',);
    $special_query = new WP_Query( $query_arguments );
    // The Loop
    if ( $special_query->have_posts() ) {
        while ( $special_query->have_posts() ) {
            // do something with the data
            // the_title();
            // the_content();
    } else {
        // no posts found
    // Restore original Post Data

    In the same way I wish to loop through all of my pages and display every single page on that main front page.

    I would use a menu here instead of making a questom query. It gives you the ability to change the menu in the future without having to go to the template page and change code. Your template code would be something like:

    // register menu location in your functions file
    // register_nav_menu('custom', __( 'Custom'));
    wp_nav_menu(array('theme_location' => 'custom'));

    Hope that helps,


    If you want to loop through Pages and display the contents of them on one page, why not….use Posts?

    I’m not trying to tell you that what you want to do is wrong, but with the way WordPress is set up, I would just say that the contents you’re trying to show should be placed in Posts.

    A Page is just one page. Nothing more, nothing less.
    A Post is meant to be shown “dynamically” — either single, or grouped, or part of it, sorted, etc.
    The Loop can be used to go through Posts, but not through Pages (at least not without some custom coding).

    Just wondering if it would just make more sense to put that content in Posts, instead of Pages. Basically — if you want to show contents of various items on the main page, then just put it in Posts (and not in Pages). That’s what they’re for, after all.


    @Senff, thanks I have gone with the post as it is easier to do. Thanks

    Also thanks Alen, I will deffo keep you solution in mind.



Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Other’ is closed to new topics and replies.