Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2006
    Posts
    88
    Thanks
    4
    Thanked 1 Time in 1 Post

    [Wordpress] 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: http://s11.postimg.org/6994o9orn/posts.jpg

    PHP Code:
    <?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 ?>
    Last edited by reyna12; 05-09-2013 at 05:05 PM.

  • #2
    New Coder
    Join Date
    Jan 2006
    Posts
    88
    Thanks
    4
    Thanked 1 Time in 1 Post
    solved

    PHP Code:
    <div id="primary" class="site-content">
            <div id="content" role="main">
            <?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);
    if(
    $pages) {
    foreach ( 
    $pages as $post ) {
        
    setup_postdata($post);
        global 
    $more;
        
    $more 0;    
    ?>

        <div onclick="location.href='<?php echo get_page_link$page->ID ); ?>';" style="cursor: pointer;" class="homebox orange<?= rand(1,3?>" id="post-<?php the_ID(); ?>">
            <h2><a href="<?php echo get_page_link$page->ID ); ?>"><?php echo $page->post_title?></a></h2>
            <?php echo get_the_post_thumbnail($page->ID'thumbnail'); ?>
            <div class="entry"><?php the_content('... Read more'); ?></div>
        </div>
            
    <?php } } ?>
    <?php wp_reset_postdata
    (); ?>

            </div><!-- #content -->
        </div><!-- #primary -->


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •