Advertisement
alchymyth

table based post columns

Jun 16th, 2012
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.56 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Template Name: News Page 1 - Template
  4.  *
  5.  * A custom page template without sidebar.
  6.  *
  7.  * The "Template Name:" bit above allows this to be selectable
  8.  * from a dropdown menu on the edit page screen.
  9.  *
  10.  * @package WordPress
  11.  * @subpackage Twenty_Ten
  12.  * @since Twenty Ten 1.0
  13.  */
  14.  
  15. get_header(); ?>
  16.  
  17. <style type="text/css">
  18. <!--
  19. body {
  20.     background:url(http://www.thejacksons.com/wp-content/uploads/2011/12/bg-header2.gif); background-repeat:repeat-x; background-position:top;
  21. }
  22. -->
  23. </style>
  24.  
  25. <style type="text/css">
  26. div.background
  27.   {
  28.   width:300px;
  29.   height:50px;
  30.   background:url(http://www.thejacksons.com/wp-content/uploads/2011/12/post_title_bg.png) repeat;
  31.   border:0px solid black;
  32.   margin:-150px 0px 0px 0px;
  33.   position:absolute;
  34.   }
  35. div.transbox
  36.   {
  37.   width:300px;
  38.   height:50px;
  39.   margin:5px 0px 0px 5px;
  40.   border:0px solid black;
  41.  
  42.   }
  43. div.transbox p
  44.   {
  45.   margin:0px 0px;
  46.   font-weight:bold;
  47.   color:#000000;
  48.   }
  49. </style>
  50.  
  51. <table width="1060" border="0" cellspacing="0" cellpadding="0">
  52.   <tr>
  53.     <td height="50" colspan="2" align="left" valign="top"><div style="margin-top:12px;"><center><img src="http://www.thejacksons.com/wp-content/uploads/2011/07/Title-Welcome.png" alt="The Only Source. Welcome to the Official Jacksons Website." width="815" height="28" border="0" /></center></div></td>
  54.   </tr>
  55.   <tr>
  56.     <td height="400" colspan="2" align="left" valign="top">
  57.  
  58. <div style="margin-left:70px; width:922px;">
  59. <table width="922" border="0" cellspacing="0" cellpadding="0" style="color:#000;">
  60.   <tr>
  61.     <td width="300" height="272" align="left" valign="top">
  62.  
  63. <?php query_posts('category_name=jackson-5-news&posts_per_page=12&tag=news12999');
  64. //automatically get the last 12 posts of the 'jackson-5-news' category with tag 'news12999' ?>
  65.  
  66. <?php while (have_posts()) : the_post(); ?>
  67.  
  68. <?php if( $wp_query->current_post && ($wp_query->current_post)%3 == 0 ) : //add table html at the start of a new line of three posts ?>
  69.   <tr>
  70.     <td height="272" align="left" valign="top">
  71. <?php endif; ?>
  72.  
  73. <!--Post Start <?php echo ($wp_query->current_post+1); ?> -->
  74. <table width="300" border="0" cellspacing="0" cellpadding="0">
  75.   <tr>
  76.     <td height="150" colspan="2" align="left" valign="top">
  77. <a class="hmfeature-links" href="<?php the_permalink() ?>">
  78. <?php the_post_thumbnail( 'single-post-thumbnail' ); ?>  
  79. </a>  
  80. <div class="background">
  81. <div class="transbox">
  82. <a class="hmfeature-links" href="<?php the_permalink() ?>">
  83. <span style="font-size:17px; line-height:1.0em;"><?php the_title(); ?></span>
  84. </a>
  85. </div>
  86. </div>
  87.     </td>
  88.     </tr>
  89.   <tr>
  90.     <td width="220" height="122" align="left" valign="top">
  91. <span style="color:#AEAEAE; font-size:11px;">Published on <?php the_time('F jS, Y') ?></span>
  92. <br />    
  93. <?php the_excerpt(); ?>
  94.     </td>
  95.     <td width="80" align="left" valign="top">
  96. <div style="margin-top:40px; height:35px; font-size:35px; color:#AEAEAE;">
  97. <center>
  98. <fb:comments-count href="<?php echo get_permalink($post->ID); ?>"></fb:comments-count>
  99. </center>
  100. </div>
  101. <span style="color:#AEAEAE;"><center>Comments</center></span>
  102.     </td>
  103.   </tr>
  104. </table>
  105. <!--Post End <?php echo $count = ($wp_query->current_post+1); ?> -->
  106. <?php if( ($wp_query->current_post+1)%3 != 0 ) : // repeat table html between posts ?>
  107.     </td>
  108.     <td align="left" valign="top">&nbsp;</td>
  109.     <td width="300" align="left" valign="top">
  110. <?php endif; ?>
  111. <?php if( ($wp_query->current_post+1)%3 == 0 && $wp_query->current_post != 11 ) : // add table html after three posts, but not at the end ?>
  112.     </td>
  113.   </tr>
  114.   <?php endif; ?>
  115. <?php endwhile; ?>
  116.  
  117. <?php if( $count < 12 ) : //add empty table cells into non-filled table rows
  118.  for($j=$count+1;$j<=(ceil($count/3)*3);$j++) { ?>
  119.     <?php if( $j%3 != 0 ) : //between posts ?>
  120.     </td>
  121.     <td align="left" valign="top">&nbsp;</td>
  122.     <td width="300" align="left" valign="top">
  123.     <?php elseif( $j%3 == 0 && $j != 12 ) : //after three posts, but not at the end ?>
  124.     </td>
  125.   </tr>
  126.     <?php endif; ?>
  127.  <?php
  128.  }
  129. endif; //ends: if( $count < 12 ) ?>
  130.  
  131.     </td>
  132.   </tr>
  133. </table>
  134. </div>
  135.  
  136. <!--end of posts and columns -->
  137.  
  138.     </td>
  139.   </tr>
  140.   <tr>
  141.     <td width="321" height="20" align="left" valign="top">&nbsp;</td>
  142.     <td width="739" align="left" valign="top">&nbsp;</td>
  143.   </tr>
  144.   <tr>
  145.     <td height="20" colspan="2" align="left" valign="top">&nbsp;
  146.  
  147.     </td>
  148.   </tr>
  149.   <tr>
  150.     <td width="321" height="20" align="left" valign="top">&nbsp;</td>
  151.     <td width="739" align="left" valign="top">&nbsp;</td>
  152.   </tr>
  153. </table>
  154.  
  155. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement