• Hi,
    i am able to get the content from a sub page and display in a page a thumb preview; yet i only want to get the image and skip the text.
    This is the code i am using:

    <ul class="thumb">
    
    <?php $pages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc&parent='.$post->ID); $count = 0; foreach($pages as $page) { $content = $page->post_content; if(!$content) continue; $count++; ?>
    <li cass="thumbList" >
    	<a href="<?php echo get_page_link($page->ID) ?>"><h1 class="title"> <?php echo $page->post_title ?> </h1>
    	<p><?php echo $page->post_content ?></p>
    
    <?php $key_1_value = get_post_meta($page->ID, 'Preview', true);
    print $key_1_value; ?>
    </a>
    
    </li>
    
    <?php
        }
    ?>
    
    </ul>

    any idea please?

Viewing 1 replies (of 1 total)
  • Thread Starter downfast

    (@downfast)

    I have found a solution and it works perfectly but i would like to understand why it only displays the image and not the text, it is actually what i wanted, but why does it do this?

    this is the code i am using now:

    <ul class="thumb">
    
    <?php $pages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc&parent='.$post->ID); $count = 0; foreach($pages as $page) { $content = $page->post_content; if(!$content) continue; $count++; ?>
    <li cass="thumbList" >
    	<a href="<?php echo get_page_link($page->ID) ?>"><h1 class="title"> <?php echo $page->post_title ?> </h1>
    	<?php echo apply_filters('the_content', $post->post_content); ?>
    
    <?php $key_1_value = get_post_meta($page->ID, 'Preview', true);
    print $key_1_value; ?>
    </a>
    
    </li>
    
    <?php
        }
    ?>
    
    </ul>

Viewing 1 replies (of 1 total)
  • The topic ‘how to only get the image from a sub page?’ is closed to new replies.