Forums

Curate Home Page Content (5 posts)

  1. jefflin
    Member
    Posted 1 year ago #

    I have a static home page, and I'd like to display a list 3-5 pages along with the pages' featured image and a brief excerpt of the content.

    Since Pages can't be added to categories, is there another method for curating pages to be displayed on the front page? Ideally, there'd be some sort of attribute I could add that allows me to query all pages that should be added to the home page.

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 1 year ago #

    you would need a page template
    http://codex.wordpress.org/Pages#Page_Templates

    Easiest way is probably a copy of page.php called something else, then add the required header
    http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates

    Then you can assign that template to your static page. Next up, to display your featured stuff, you'd need a custom query before the loop
    http://codex.wordpress.org/Function_Reference/query_posts

    specifically
    http://codex.wordpress.org/Function_Reference/query_posts#Post_.26_Page_Parameters
    for page parameters

    once the proper stuff is queried, you edit the loop to show what you wish

  3. jefflin
    Member
    Posted 1 year ago #

    Thanks Rev Voodoo. Here's the solution I came up with

    <?php
      global $post;
      $args = array(
        'numberposts' => 5,
        'post_type' => 'any',
        'meta_key' => 'frontpage',
        'orderby' => 'rand'
         );
      $myposts = get_posts( $args );
      foreach( $myposts as $post ) : setup_postdata($post); ?>
        <div class="front-page-post">
          <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
          <div class="front-page-post-text">
            <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
            <?php the_excerpt(); ?>
          </div>
        </div>
    <?php endforeach; ?>

    What this allows the user to do is just specify a custom field "frontpage" on either a post or a page and it shows up on the front page.

  4. Gnuboss
    Member
    Posted 10 months ago #

    Hi Jefflin,

    This is not related to the thread, but I don;t know how else to get in touch.

    Interested in doing some more WordPress Widget dev similar to what you guys did for BB?

    Regards,
    Bronson.

  5. jefflin
    Member
    Posted 10 months ago #

    Hi Gnuboss. Hit me up at jeff@bustoutsolutions.com.

Topic Closed

This topic has been closed to new replies.

About this Topic