Support » Theme: Hamilton » Featured Work Page

  • Resolved mattfrieder


    I’m trying to edit the code (via a child-theme) to display projects/blog thumbnails and titles similar to the home page gallery. See theme example here.Along with other numerous troubleshooting, I’ve tried adding the following code block from index.php into singular.php with no luck (it only displays a single greyed out fallback image with the current page title):

    <?php if ( have_posts() ) : ?>
      <div class="posts" id="posts">
        <?php while ( have_posts() ) : the_post();
          get_template_part( 'content' );
        endwhile; ?>
    <?php endif; ?>


Viewing 4 replies - 1 through 4 (of 4 total)
  • Theme Author Anders Norén


    Hi @mattfrieder,

    You’ll need to setup a custom loop that queries the latest posts – the have_posts() loop, when used on a single post/page, will only include the post object of the post/page being viewed.

    You can find more information, and some example code (check the user contributed notes), here:

    — Anders

    Thread Starter mattfrieder


    Thank you @anlino !

    For anyone looking to create similar, I achieved it with this custom code block in singular.php, between the ‘page-header’ and ‘content’:

    <!-- Display posts if page name is "Featured Work" -->
    <?php if ( is_page( "Featured Work" ) ) : ?>
      <div class="posts" id="posts">
        <?php $postslist = get_posts( array(
          'order'          => 'ASC',
          'orderby'        => 'rand',
          // Display posts only in certain category option:
          // 'category_name'  =>	'category-slug'
        ) );
        if ( $postslist ) {
          foreach ( $postslist as $post ) :
            setup_postdata( $post );
            get_template_part( 'content' );
      } ?>
    <?php endif; ?>
    </div> <!-- .posts -->
    • This reply was modified 12 months ago by mattfrieder.


    I did something similar but made it into a shortcode that can be used all over.

    WordPress Hamilton Theme add-on

    • This reply was modified 12 months ago by seindal.
    Thread Starter mattfrieder


    Awesome @seindal , thats a great idea. I’ll definitely take a look, thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Featured Work Page’ is closed to new replies.