page excerpts instead of post excerpts on homepage?
-
Hi there,
I am looking to have several excerpts of pages displayed on the homepage as a grid/small boxes, rather than “blog posts”.
The current code i have is below. I was wondering how i make it display a “read more” link and just a short description as it just display all the content on that page. Also, how to show the featured image as a thumbnail?
You can see what is happening here: https://s11.postimg.org/6994o9orn/posts.jpg
<?php $args = array( 'sort_order' => 'ASC', 'sort_column' => 'post_title', 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'meta_key' => '', 'meta_value' => '', 'authors' => '', 'child_of' => 0, 'parent' => -1, 'exclude_tree' => '', 'number' => '', 'offset' => 0, 'post_type' => 'page', 'post_status' => 'publish' ); $pages = get_pages($args); foreach ( $pages as $page ) { $content = $page->post_content; ?> <div onclick="location.href='<?php echo get_page_link( $page->ID ); ?>';" style="cursor: pointer;" class="homebox orange<?= rand(1,3) ?>" id="thickbox post-<?php the_ID(); ?>"> <h2><a href="<?php echo get_page_link( $page->ID ); ?>"><?php echo $page->post_title; ?></a></h2> <div class="entry"><?php echo $content; ?></div> </div> <?php } ?>
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘page excerpts instead of post excerpts on homepage?’ is closed to new replies.