Support » Themes and Templates » Photographic theme how to get last post from each category on home

  • Hi,

    I am only just beginning to learn about php and css so far so good. I am using the photographic theme:

    http://wordpress.org/extend/themes/photographic

    Currently I have a list of the current posts in date order on the index page however I want to change this to show last post (i.e. picture + date and title) from each category (excluding some categories if possible)

    I have tried a number of solutions I found around here, but I have not managed to find the correct one.

    The index template I have currently is:

    <?php get_header(); ?>
    
    	<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
          <?php if(has_post_format( 'gallery' )) { //gallery ?>
    
            <article <?php post_class() ?> id="post-<?php the_ID(); ?>">
              <a href="<?php the_permalink() ?>">
                <?php if ( has_post_thumbnail() ) { the_post_thumbnail('medium-square'); } else { ?>
                  <img src="<?php echo get_template_directory_uri(); ?>/img/oops.png" width="200" height="200" />
                <?php } ?>
                <strong><?php the_title(); ?></strong>
              </a>
            </article>
    
            <?php } elseif(has_post_format( 'image' )) { //image ?>
    
              <article <?php post_class() ?> id="post-<?php the_ID(); ?>">
                <a href="<?php the_permalink() ?>">
                  <?php if ( has_post_thumbnail() ) { the_post_thumbnail('medium-square'); } else { ?>
                    <img src="<?php echo get_template_directory_uri(); ?>/img/oops.png" width="200" height="200" />
                  <?php } ?>
                  <strong><?php the_title(); ?></strong>
                  <?php the_category(); ?>
                </a>
              </article>
    
          <?php } else { // normal post format ?>
    
            <article <?php post_class() ?> id="post-<?php the_ID(); ?>">
             <a href="<?php the_permalink() ?>">
                <time><?php the_time(get_option('date_format')) ?></time>
                <?php if ( has_post_thumbnail() ) { the_post_thumbnail('medium-square'); } else { ?>
                  <img src="<?php echo get_template_directory_uri(); ?>/img/dbrfinal.jpg" width="200" height="200" />
                <?php } ?>
                <strong><?php the_title(); ?></strong>
                </a>
            </article>
    
          <?php } ?>
    
    		<?php endwhile; ?>
    
    			<ul class="prevnext">
    				<li><?php next_posts_link('< Older Entries') ?></li>
    				<li><?php previous_posts_link('Newer Entries >') ?></li>
    			</ul>
    
    	<?php else : ?>
    
    		<article class="noposts">
    			<h2>404 - Content Not Found</h2>
    			<p>We don't seem to be able to find the content you have requested - why not try a search below?</p>
    			<?php get_search_form(); ?>
    		</article>
    
    	<?php endif; ?>
    
    <?php get_footer(); ?>

    WP is a wonderful blogging tool, I can’t wait to get more into it. Thanks for you time.

  • The topic ‘Photographic theme how to get last post from each category on home’ is closed to new replies.