2

How to display attached thumbnail and excerpt (about 200 words) of a page on homepage?

<?php 
$page_data = get_page( 401 ); // Get page ID 401
echo '<h3>'. $page_data->post_title .'</h3>';
echo apply_filters('the_content', $page_data->post_content);
?>

I don't know how to display attached image as thumbnail. May be i use mb_substr php function to cut the content to the excerpt.

Sorry, my english is not good. :) Thanks for help!

3
  • i've tried with get_page function. But i can't get the page excerpt & attached thumbnail with it. tks for help.
    – Bits Hcm
    Nov 14 '12 at 4:05
  • Please edit the question and paste the code that you used.
    – s_ha_dum
    Nov 14 '12 at 5:25
  • i've edit and update the question. thanks all very much. :)
    – Bits Hcm
    Nov 14 '12 at 6:48
0
<?php $post_id = 50; // assign post id
                $queried_post = get_page($post_id);
                if(is_home()) {  ?>
                <div class='product_title'><h3><a href="<?php echo get_page_link($post_id); ?>"><?php echo $queried_post->post_title;  ?></a></h3></div>                    
                <div class='product_image_location'><?php echo get_the_post_thumbnail( $post_id); ?></div>
                <div class='description_product'>
                <?php echo $queried_post->post_content;  ?></div>
            <?php  } ?>
1
  • 2
    You should really start with the is_home() check. Otherwise you would send the extra query on each request.
    – fuxia
    Nov 14 '12 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.