WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Display Featured Images From Pages on One Main Page (3 posts)

  1. RE20
    Member
    Posted 1 year ago #

    I am trying to display all my pages featured images in custom manner on one main page.

    I have found this:
    <?php $featured_image = new WP_Query('page_id=114'); ?>
    <?php while ($featured_image->have_posts()) : $featured_image->the_post(); ?>

    <?php if (function_exists('has_post_thumbnail') && has_post_thumbnail()) { ?>

    <?php $img_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), array( 205,168 )); ?>

    <div class="the-image">
    "><img src="<?php echo $img_src[0]; ?>" />
    </div>

    <?php }; ?>

    <?php endwhile; ?>
    <?php wp_reset_query(); ?>

    It works, BUT only for a selected page and I want all my pages that have them. Also the permalink doesn't work.

    Any and all help would be great!!!

  2. RE20
    Member
    Posted 1 year ago #

    FOUND IT FOR ANYONE ELSE

    <?php query_posts(array('child_of' => 0, 'post_type' => 'page')); while (have_posts()) { the_post(); ?>

    <div class="blind-subpage">

    <?php if ( has_post_thumbnail() ) {?>

    <?php the_post_thumbnail(); ?>
    <?php the_title() ?>

    <?php } else { ?>

    <!-- Else Don't show anything -->

    <?php } ?>

    <!-- closes blind-subpage -->
    </div>

    <?php } ?>

  3. alsc
    Member
    Posted 1 year ago #

    Do you have a link for the page, where you have inserted the code?

    Thank you.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.