Advertisement
dangermoose

courses

Jan 27th, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.55 KB | None | 0 0
  1. <?php
  2.  
  3. /* Template Name: My Template*/
  4.  
  5.     function custom_get_the_excerpt( $post_id, $auto_generate = true, $length = 21, $ellipsis = '...' ) {  
  6.         $post = get_post( $post_id );
  7.         $excerpt = $post->post_excerpt;
  8.    
  9.         if ( !$excerpt && $auto_generate ) {
  10.             $content = strip_tags( strip_shortcodes( $post->post_content ) );
  11.             $content = preg_replace( '/\s+/', ' ', $content );
  12.             $words = explode( ' ', $content );
  13.             if ( count( $words ) > $length )
  14.                 $excerpt = implode( ' ', array_slice( $words, 0, $length ) ) . $ellipsis;
  15.             else
  16.                 $excerpt = $content;
  17.         }  
  18.         return $excerpt;
  19.     }
  20.  
  21. get_header();?>
  22. <style>
  23.     div.courseaction a.greybutton
  24.     {
  25.         float:left;
  26.     }
  27. </style>
  28.         <div id="container">
  29.             <div id="content" role="main">
  30.            
  31.             <?php echo "<h2>" . get_the_title() . "</h2>"; ?>            
  32.            
  33.             <div id="genericpaneltop" style="margin-top:25px">&nbsp;</div>
  34.                  <div id="genericpanel">
  35.                                
  36.                 <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
  37.                                
  38.                                     <div class="entry-content">
  39.                                         <?php the_content(); ?>
  40.                                         <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
  41.                                         <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?>
  42.                                     </div><!-- .entry-content -->
  43.                                 </div><!-- #post-## -->
  44.                
  45.                                 <?php comments_template( '', true ); ?>
  46.                
  47.                 <?php endwhile; // end of the loop. ?>            
  48.            
  49.  
  50.                  <div id="coursepaneltop" style="margin-top:25px">&nbsp;</div>
  51.                 <div id="coursepanel">
  52.                         <?php
  53.                             // Choose the icon to be displayed
  54.                             if (get_the_title()=="My Course 1") {$coursetypeimg = "courses_small.png";}
  55.                 if (get_the_title()=="My Course 2") {$coursetypeimg = "courses_small.png";}
  56.                 if (get_the_title()=="My Course 3") {$coursetypeimg = "courses_small.png";}
  57.                             if ($_GET["paged"]!="")
  58.                             {
  59.                                 $offset = ($_GET["paged"] * 10)-10;
  60.                             }
  61.                             else
  62.                             {
  63.                                 $offset=0;
  64.                             }      
  65.                            
  66. $querytxt = 'depth=0&orderby=menu_order date&posts_per_page=15&post_type=page&post_parent='.$post->ID. "&offset=".$offset;  // Look for courses in this section
  67.                           //  $courselist = new WP_Query( $querytxt );
  68.                             query_posts($querytxt);
  69.                             while ( have_posts() ) : the_post();
  70.                            
  71.                                 $thumburl =  wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),'');
  72.                                 $img = $thumburl[0];
  73.                         ?>
  74.                         <!-- start of a course box -->
  75.                             <div class="coursebox">
  76.                                 <div class="courseimage"><img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo $img ?>&w=150&h=100&zc=1" /></div>
  77.                                 <div class="coursetypeicon"><img src="<?php bloginfo('template_directory'); ?>/images/coursetypes/<?php echo $coursetypeimg ?>" width="27" height="27" /></div>
  78.                                 <div class="coursetitle">
  79.                                     <?php /*?><?php echo $p->post_title; ?><?php */?>
  80.                                     <h2 class="entry-title"><a href="<?php echo get_permalink($post->ID) ?>" class=""><?php echo $post->post_title; ?></a></h2>
  81.                                 </div>
  82.                                 <div class="coursedetails">
  83.                                
  84.                                     <div class="coursetext">
  85.                                     <?php echo custom_get_the_excerpt($post->ID,true,50); ?>    
  86.                                     </div>
  87.                                    
  88.                                    
  89.                                     <div class="courseaction" style="display:inline-block;float:left;margin-top:11px;">
  90.                                     <a class="greybutton" href="<?php echo get_permalink($post->ID) ?>" title="<?php echo $post->post_title; ?> - Read More">More Info</a>             
  91.                                  </div>
  92.                                          
  93.                                          <div style="display:inline-block;float:left;">
  94.                                           <!-- Custom field for Product ID-->
  95.                                        
  96.                                         <?php $values = get_post_custom_values('Product_ID',$post->ID);
  97.                                          if ($values){
  98.                                              ?>
  99.                                         <?php echo get_button_code_for_product($values[0]); ?>
  100.                                         <?php } else { ?>
  101.                                           <p></p>
  102.                                           <?php } ?>
  103.  
  104.                                          <!-- End Custom field for Product ID-->
  105.                                          
  106.                                         </div> 
  107.                                                
  108.                                 </div>
  109.  
  110.                                
  111.                             </div>
  112.                         <!-- end coursebox -->
  113.                         <div style="clear:both;"></div>
  114.                 <?php
  115.                     endwhile;
  116.                     //} // end of the loop.
  117.                    
  118.                    
  119. ?>
  120.  
  121.                     </div><!-- coursepanel -->
  122.                    
  123.                                        
  124. <?php /* Display navigation to next/previous pages when applicable */ ?>
  125. <?php if ( $wp_query->max_num_pages > 1 ) { ?>
  126.         Page <?php echo $paged; ?> of <?php echo $wp_query->max_num_pages; ?>
  127.  
  128.         <?php for ($x=1; $x<=$wp_query->max_num_pages;$x++)  {
  129.        
  130.         if($x==$paged)
  131.         {
  132.             $highlight="background-color:#444;color:#fff;";
  133.         }
  134.         else
  135.         {
  136.             $highlight="";
  137.         }
  138.         echo '<a style="'.$highlight.'border:1px #ccc solid;padding:2px 5px;display:inline-block;margin:6px 4px;" href="/index.php?page_id=29&paged='. $x. '" class="page larger">'. $x. '</a>';
  139.  
  140. } ?>
  141.  
  142. <!-- #nav-above -->
  143. <?php }//endif; ?>
  144.  
  145.             </div><!-- #content -->
  146.         </div><!-- #container -->
  147.  
  148. <?php get_sidebar('courses'); ?>
  149. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement