Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7006037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:25:35+00:00 2026-05-27T21:25:35+00:00

I have one page (not an article) with n subpages. In the main page,

  • 0

I have one page (not an article) with n subpages.
In the main page, I need to show max 3 titles of the subpages and insert a pagination for the other.

How can I do that?

This is my simple code now:

<?php 
    $parent_id = 14; //main page id
    $pages = get_pages( array( 'sort_column' => 'menu_order', 'numberposts' => 3, 'child_of' => $parent_id ) );
    foreach ( $pages as $page ) : ?>
        <div class="item">
            <div class="item-title">
                <h2><a href="<?php echo get_permalink( $page->ID ); ?>"><?php echo $page->post_title; ?></a></h2>
            </div>
        </div>
    <?php endforeach; ?>

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:25:36+00:00Added an answer on May 27, 2026 at 9:25 pm

    I solved by myself, the solution is to use wp_query() to create a new loop insted of using get_pages().

    Here the new code for page title and contentwith pagination by Preeti Dua from Avigma Technology:

        <?php
    
        // Pagination variable
        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
        // The Query
        $the_query = new WP_Query( array( 'post_parent' => 782, 'post_type' => 'page', 'paged' => $paged) );
    
        // The Loop
        if($the_query->have_posts()) : while($the_query->have_posts()) : $the_query->the_post();
        global $post;
        $thePostID = $post->ID; /* this variabled is used if you need to get custom fields of the subpage */
            ?>
        <div id="side-post-title">
            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
        </div>
    
         <div id="side-post-excerpt">
                   <?php the_excerpt(); ?>
    
                 <a href="<?php echo get_permalink( $page->ID ); ?>"> <div id="read-more"> 
                           <img src="/wp-content/uploads/2012/10/read-more-btn.png"/></div> </a>                                                          
          </div> 
    
    
    
    <?php endwhile; endif; ?>
    
    <nav class="navigation">
       <div style="float:left;"> <?php next_posts_link('Show older', $the_query->max_num_pages) ?></div>
       <div style="float:right;"> <?php previous_posts_link('Show newer') ?></div>
    </nav>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need some help from javascript gurus. I have one page where http://www.google.com/finance/converter is embedded
I need to have two different Like buttons on one web-page. First one -
I have one Page which is displaying details of some Client. I am using
I have one page with a Silverlight object on it, and many times when
I have one page website only using HTML, CSS and JavaScript. I want to
In my project I have one table with 24*6*300 cells on one page (it's
I'm doing an asp.net application with one page. In this page, I have one
I have Application written with GWT 1.7. I have one page where I upload
i am porting over a website from asp. i have one page that i
I have one master page which applies to all pages in this website. On

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.