Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am after some guidance with the following HTML to WordPress conversion.

Based on the linked image (see HTML Divs screen image), which has the following three divs, which will be individual pages within my WordPress site, after conversion, i.e.:

see:> html Divs

1) Solar Pool Heating
2) Domestic Hot Water &
3) Solar Electric

Can somebody please let me know how through the use of the WordPress loop and built in functions, I can obtain the image for each div from the main page as well as an excerpt of the page content for each of the divs together with the "Read More" which would then take me to the actual page to read all of the page?

I'm not sure if this is possible but I have always wanted to know how this can be done as this would assist my understanding of this area.

Hopefully someone can assist.

Thanks.

share|improve this question

1 Answer 1

You can load content from other pages via the get_pages function:

<?php
$args = array(
    'sort_column' => 'menu_order',
    'include' => array( 5, 6, 7 ) // your page IDs
);
$my_pages = get_pages( $args );

foreach( $my_pages as $page ){
    setup_postdata( $page );
    the_title();
    the_post_thumbnail();
    the_excerpt();
    the_permalink();
}
wp_reset_postdata();
?>
share|improve this answer
    
Thanks Milo but can I ask you a few queries, how does the_post_thumbnail() function work - does it just grab any image attached to that page id? Also, how does the_excerpt() function work - say I just want to pick up the first 50 chars of the page id, which may consist of two paragraphs in that 50 chars? Does a substr() need to be performed or does the excerpt get placed elsewhere? Thanks. –  softprinciples Mar 20 '12 at 23:53
    
@softprinciples see the_excerpt, the_post_thumbnail, and Post Thumbnails in codex. –  Milo Mar 21 '12 at 0:35
    
unfortnately I cannot get the get_pages to work for me. Tried the code above and it didn't retrieve back anything? Any help would be appreciated. thanks. –  softprinciples Mar 23 '12 at 14:08
    
@softprinciples - did you change the page ids to your pages? I'd have to see it in context as it works for me. what do you see when you print_r($my_pages); after the get_pages call? –  Milo Mar 23 '12 at 15:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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