• This may be asking too much… but let’s see. This wonderful code here goes and gets the children of a page, and lists the title and attached picture (floated left), as well as the content before the MORE tag, and ends with a beautiful little “read more…” linked to the page.

    Question: is it possible to get some code that will print the picture attached (floated left) but in the thumbnail size specified in the media preferences instead of the full size it appears in the page?

    thanks
    JSC
    the code:

    <?php
        $args=array(
          'post_type' => 'page',
          'post_parent' => 93,
          'post_status' => 'publish',
          'posts_per_page' => -1,
          'caller_get_posts'=> 1
          );
        $my_query = null;
        $my_query = new WP_Query($args);
        if( $my_query->have_posts() ) {
          echo 'List of Child Pages for Page ID 93';
          while ($my_query->have_posts()) : $my_query->the_post(); ?>
            <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
            <?php
            global $more; $more = false;
            the_content('Read on....');
          endwhile;
        }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter jami1955

    (@jami1955)

    Nice one. Unfortunately, this code is not within the loop… thanks tho.

    There’s others : get_the_post_thumbnail(), get_image(), …. but dunno if they works with pages and outside the loop. Can’t check at the moment because codex.wordpress.org seems off. Might be until the team see the trouble Monday I guess…

    Another way would be using custom fields in the admin new page form, where you enter the url and then call it in php with

    <?php
    $image_url = get_post_meta($post->ID, "NameOfYourCustomField", true);
    if ( !empty($image_url ) ) : ?>
         <img src="<?= $image_url ?>" alt="thumbnail" style="float: left;" />
    <? endif; ?>

    But I think it doesn’t answer you question as it doesn’t use the thumbnail size specified in the media preferences.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘List child page, and make attached picture thumbnail’ is closed to new replies.