ThemeShaper Forums » Thematic


Homepage with static and dynamic content

(2 posts)
  • Started 7 years ago by EddieY
  • Latest reply from ScottNix
  • This topic is resolved
  1. EddieY

    I wanted to have my homepage feature static and dynamic content. The bottom-half would feature my six latest posts in a 3-column format like it is featured on this website

    I know I have to create a template and assign it to the page, which I have done, but I'm confused as to which code I must put in to achieve this effect?

    Any help would be greatly appreciated.

    Posted 7 years ago #
  2. To get started, I would recommend

    While that runs on posts tagged "featured", it can easily be modified to do different things.

    I modified it to include the image thumbnail, if one wasn't available it would use a default (the else part), I was using a version of it for a while on my site but don't any longer, so this may help.

    $my_query = new WP_Query( array( 'tag_slug__in' => array( featured ), 'posts_per_page' => 2 ) );
    echo '<ul class="featured-posts">';
    $feat_class = array();
    while ($my_query->have_posts()) : $my_query->the_post();
    		$feat_class = array();
    		// Category for the post queried
    		foreach ( (array) get_the_category() as $cat )
    			$feat_class[] = 'category-' . $cat->slug;
    			$feat_class = join(" ", $feat_class);
    		<li id="featured-<?php the_ID(); ?>" class="<?php echo $feat_class; ?>">
    				$posttitle = '<h3><a href="';
    				$posttitle .= get_permalink();
    				$posttitle .= '" title="';
    				$posttitle .= the_title_attribute('echo=0');
    				$posttitle .= '" rel="bookmark">';
    				$posttitle .= get_the_title();
    				$posttitle .= "</a></h3>\n";
    				echo $posttitle;
    				if ( has_post_thumbnail() ) { ?> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail(); ?></a><?php
    				else { ?> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute('echo=0'); ?>"><img height="120" width="210" src="<?php bloginfo('stylesheet_directory'); ?>/images/testimage.png" /></a><?php
    echo '</ul>';

    If you wanted to modify the logic (so it does something other than grab posts with the tag "featured", then you will want to modify the parameters which can be found here

    The styling to do a 3 column would all be CSS.

    Posted 7 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.