• I would really like to display multiple pages on one page. I have looked at a number of similar questions and examples, but as a complete beginner in WordPress, I am struggling a bit. I would like to be able to do it on the pages themselves by using inline php (I am using Insert PHP plugin), and would really like some advice on this.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter martinbelton

    (@martinbelton)

    twenttwelve

    Thread Starter martinbelton

    (@martinbelton)

    I don’t suppose it would be possible to give me an example? As a newcomer, I am finding it a little difficult following the codex pages at the moment. I presume I have to revert to the default permalinks to find the page_id first?

    display multiple pages on one page

    basic example using WP_Query():

    <?php
    $args = array(
      'post_type' => 'page',
      'post__in' => array( 2, 5, 35, 67 ) //list of page_ids
    );
    $page_query = new WP_Query( $args );
    if( $page_query->have_posts() ) :
    echo '<div class="pages-on-page">';
    //print any general title or any header here//
    while( $page_query->have_posts() ) : $page_query->the_post();
    echo '<div class="page-on-page" id="page_id-' . $post->ID . '">';
    //print any output you want per page//
    echo '</div>';
    endwhile;
    echo '</div>';
    else:
    //optional text here is no pages found//
    endif;
    wp_reset_postdata();
    ?>

    (not tested)

    Thread Starter martinbelton

    (@martinbelton)

    Thank you very much for this – I can’t seem to implement it though. I have pasted this into a page, changing list of page_ids to fit, using [insert_php]...[/insert_php] instead of <?php ... ?> using this plugin. Should I be adding it into a php file instead? (The pages.php file in them folder?) If so, should I be replacing some part of the original code with this, or just adding it in?

    Martin, forget the plugin.

    You haven’t stated exactly what content you want to display.

    Just the page titles, excerpts or full content of each page?

    For Linked Page Titles Only:

    You can also use wp_list_pages if you only want the title

    <?php wp_list_pages('include=7,13,26,35&title_li=' ); ?>

    Displays a list of WordPress Pages as links

    You can use the tag directly in any template file or in a custom function with hook and conditional tag.

    Otherwise, use the new WP_Query code above by alchymyth however you will need to add tags for the excerpt, content or get_template_part here (//print any output you want per page//) as it doesn’t include them and will display nothing as is.

    Thread Starter martinbelton

    (@martinbelton)

    @ Brad Dalton – thank you! finally managed it – thank you so much for your help – breakthrough at last!!

    Thread Starter martinbelton

    (@martinbelton)

    What command do I need to include the content?

    You can use the content template tag which you can grab from one of the files. Or you could use the_excerpt.

    You still haven’t answered the question

    You haven’t stated exactly what content you want to display.

    Hi ,

    If you want to include the content of the pages then how should you go about it .

    Hi guys, I’m having similar issue. I would like to be able to add multiple pages to a page. Kind of like this site here- https://vickyflipfloptravels.com/category/weekender/
    I dont know how to go about it and would really appreciate if anyone could assist with this.

    Many thanks,
    Mary

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘display multiple pages on one page’ is closed to new replies.