treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] Doing a Custom home.php in wordpress

  • I'm thinking of making a custom home.php in wordpress. And i want it to feed from different categories from the news blog. Here is the link for the test, http://visualdesignworkshop.com/test/
    I want to know is there is correct to do like this!?

    and the code is:

      <div class="main_container"><!--START MAIN_CONTAINER -->    
    
      <div class="main_content">
    
      <?php query_posts( array(
              'posts_per_page' => 1,
              'cat' => 87,
              'post_type' => 'post',            
              'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ),
        ));
      ?>        
    
      <div class="h_colorborder"><h1>Plugins</h1></div>
    
      <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> 
    
        <div class="headerh2"><h2 class="headerh2color"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2></div>
    
          <a href="<?php the_permalink(); ?>">
          <img class="blogphoto" src="<?php $thumb = get_post_custom_values('post-image'); echo $thumb[0]; ?> " alt="<?php the_title(); ?>" /></a>
    
          <div class="excerpt">
          <?php the_excerpt(); ?>
          </div>
    
          <?php endwhile;?>
    
          <?php include (TEMPLATEPATH . '/inc/nav.php' ); ?>
          <?php else : ?>
    
            <p>Searching and there isn't there!</p>
    
          <?php endif; ?>   
    
        <?php wp_reset_query(); ?>
    
      </div> <!-- END MAIN CONTENT -->
    
      <div class="main_content"><!-- START MAIN CONTENT -->
    
      <?php query_posts( array(
              'posts_per_page' => 1,
              'cat' => 88,
              'post_type' => 'post',            
              'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ),
        ));
      ?>        
    
      <div class="h_colorborder"><h1>Apps</h1></div>
    
      <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> 
    
        <div class="headerh2"><h2 class="headerh2color"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2></div>  
    
          <a href="<?php the_permalink(); ?>">
          <img class="blogphoto" src="<?php $thumb = get_post_custom_values('post-image'); echo $thumb[0]; ?> " alt="<?php the_title(); ?>" /></a>
    
          <div class="excerpt">
          <?php the_excerpt(); ?>
          </div>
    
          <?php endwhile;?>
    
          <?php include (TEMPLATEPATH . '/inc/nav.php' ); ?>
          <?php else : ?>
    
            <p>Searching and there isn't there!</p>
    
          <?php endif; ?>   
    
        <?php wp_reset_query(); ?>
    
      </div> <!-- END MAIN CONTENT -->  
    
  • This the example of only two queries and on the page they are 4. So is this correct to put on home.php as static and use the news blog with pagination and all as usual. So the home.php feeds from differents categories of the latest. What do you think?

  • That's pretty much how you would do it. Is there any particular question you have?

  • Mostly about this, i was little unsure if this is the way to go for a custom home.php, so i don't mess it up. I'm still learning this crazy php..hehe..i'm not even a webdesigner, i'm a 3d artist. :) So building as much as possible myself for keeping down the costs. I'm going to hire for the webshop and more difficult stuff. So this a go if you don't have any other suggestion?

  • You've got the resets in there, which is good.

    I'd probably try to utilize some HTML5 elements like article, but as long as it's working I think you're good to go.

  • Nice, yes i'll try to use. I need only change Main container and the css, should work correctly after that i hope :) Thanks for the help!

  • maybe even go with sections...hehe..