36 posts
  • Has collected 100+ items on Envato Market
  • Located in United States
  • Has been part of the Envato Community for over 5 years
  • Sells items exclusively on Envato Market
danyno45 says
Hello everyone, Its been a week i am reading and trying every code that i have found on the net to “Show list of Child pages and Featured Image on Current Page” i really tried everything and nothing seems to work. I am using the Avada theme. Please help thank you in advance
Thats my last try :(
    <?php
    $child_pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = ".$post->ID." AND post_type = 'page' ORDER BY menu_order", 'OBJECT'); ?>
    <?php if ( $child_pages ) : foreach ( $child_pages as $pageChild ) : setup_postdata( $pageChild ); ?>
    <div class="child-thumb">
    <?php echo get_the_post_thumbnail($pageChild->ID, 'thumbnail'); ?>
    <a href="<?php echo get_permalink($pageChild->ID); ?>" rel="bookmark" title="<?php echo $pageChild->post_title; ?>"><?php echo $pageChild->post_title; ?></a>
    </div>
    <?php endforeach; endif;
    ?>
41 posts
  • Has collected 1+ items on Envato Market
  • Located in United Kingdom
  • Sells items exclusively on Envato Market
  • Has been part of the Envato Community for over 1 year
Makins says

You’ll need to run with this, but it should help point you in the right direction. Put this in the loop for your page (in page.php):

    $page_query = new WP_Query();
    $all_pages = $page_query->query( array('post_type' => 'page') );

    $page_children = get_page_children( get_the_id(), $all_pages );
    $current_page = $page_children[0];

    echo '<ul>';
    echo '<li>' . get_the_post_thumbnail( $current_page->ID, 'thumbnail' ) . $current_page->post_title . '</li>';
    echo '</ul>';
36 posts
  • Has collected 100+ items on Envato Market
  • Located in United States
  • Has been part of the Envato Community for over 5 years
  • Sells items exclusively on Envato Market
danyno45 says

You’ll need to run with this, but it should help point you in the right direction. Put this in the loop for your page (in page.php):
    $page_query = new WP_Query();
    $all_pages = $page_query->query( array('post_type' => 'page') );

    $page_children = get_page_children( get_the_id(), $all_pages );
    $current_page = $page_children[0];

    echo '<ul>';
    echo '<li>' . get_the_post_thumbnail( $current_page->ID, 'thumbnail' ) . $current_page->post_title . '</li>';
    echo '</ul>';

Thank you so much for your reply… Could you please reply with the whole block code i need to add to page.php. Thanks

41 posts
  • Has collected 1+ items on Envato Market
  • Located in United Kingdom
  • Sells items exclusively on Envato Market
  • Has been part of the Envato Community for over 1 year
Makins says

That code on it’s own should work, provided you paste it into the loop. I don’t know what’s in Avada’s page.php, so I can’t give you any more detail than that I’m afraid.

36 posts
  • Has collected 100+ items on Envato Market
  • Located in United States
  • Has been part of the Envato Community for over 5 years
  • Sells items exclusively on Envato Market
danyno45 says

It worked, thanks a lotttt Makins :)

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by