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

  • Home
  • SEARCH
  • 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 7988997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:37:20+00:00 2026-06-04T12:37:20+00:00

here is my custom code this will list all page from specific parent but

  • 0

here is my custom code this will list all page from specific parent but now, how to show every row only 4 result, and last row will have class ‘last’.

<?php

        //this is custom query for show page from specific parent page in different page        

        $child_pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = '11' AND post_type = 'page' ORDER BY menu_order", 'OBJECT'); 
        if ( $child_pages ) : foreach ( $child_pages as $pageChild ) : setup_postdata( $pageChild ); ?>         

        <div class="child-thumb_home looping">

            <div class="property_thumb"><a href="<?php echo  get_permalink($pageChild->ID); ?>"><?php echo get_the_post_thumbnail($pageChild->ID, array(222,123)); ?></a></div>

            <a href="<?php echo  get_permalink($pageChild->ID); ?>" rel="bookmark" class="property_name" title="<?php echo $pageChild->post_title; ?>">
            <?php echo $pageChild->post_title; ?>
            </a>

            <div class="some_desc"><?php the_advanced_excerpt('length=50&use_words=0&no_custom=1&ellipsis=%26hellip;&exclude_tags=img,p,strong'); ?></div>

            <div class="read_more"><a href="<?php echo  get_permalink($pageChild->ID); ?>">MORE INFO...</a></div>

        </div>   

        <?php endforeach; endif; ?>

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-06-04T12:37:22+00:00Added an answer on June 4, 2026 at 12:37 pm

    Change this line:

    $child_pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = '11' AND post_type = 'page' ORDER BY menu_order", 'OBJECT'); 
    

    To:

    $child_pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = '11' AND post_type = 'page' ORDER BY menu_order LIMIT 4", 'OBJECT'); 
    

    And these lines:

    if ( $child_pages ) : foreach ( $child_pages as $pageChild ) : setup_postdata( $pageChild ); ?>         
        <div class="child-thumb_home looping">
    

    To:

    $num_child_pages = count($child_pages);
    if ( $num_child_pages ) : for ($i = 0; $i < $num_child_pages; $i++):
        $pageChild = $child_pages[$i];
        setup_postdata( $pageChild ); ?>
    
        <div class="child-thumb_home looping <?php if ($i == $num_child_pages - 1): ?>last<?php endif; ?>">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this code to show a dialog box that will confirm for
Suppose we have this example: http://techdroid.kbeanie.com/2009/07/custom-listview-for-android.html with source code available here: http://code.google.com/p/myandroidwidgets/source/browse/trunk/Phonebook/src/com/abeanie/ How can
Here is my code i am using for custom search, <div id=cse-search-form style=width: 100%;>Loading</div>
Here's the code I'm using to make a custom AlertDialog. public void onButtonClicked(View v)
I implemented a custom Profile object in code as described by Joel here: How
I build my own widget with dojo as discussed here: Custom Widget Now, I
From My Previous question sending request to apple - from iphone custom application Here,
I needed to create a custom select list for the user registration page that
I am using a custom List adapter to display a list of all contacts,
I would like to write a ItemsControl derived custom control. This is partially from

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.