Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* Template Name: My Template*/
- function custom_get_the_excerpt( $post_id, $auto_generate = true, $length = 21, $ellipsis = '...' ) {
- $post = get_post( $post_id );
- $excerpt = $post->post_excerpt;
- if ( !$excerpt && $auto_generate ) {
- $content = strip_tags( strip_shortcodes( $post->post_content ) );
- $content = preg_replace( '/\s+/', ' ', $content );
- $words = explode( ' ', $content );
- if ( count( $words ) > $length )
- $excerpt = implode( ' ', array_slice( $words, 0, $length ) ) . $ellipsis;
- else
- $excerpt = $content;
- }
- return $excerpt;
- }
- get_header();?>
- <style>
- div.courseaction a.greybutton
- {
- float:left;
- }
- </style>
- <div id="container">
- <div id="content" role="main">
- <?php echo "<h2>" . get_the_title() . "</h2>"; ?>
- <div id="genericpaneltop" style="margin-top:25px"> </div>
- <div id="genericpanel">
- <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
- <div class="entry-content">
- <?php the_content(); ?>
- <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
- <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?>
- </div><!-- .entry-content -->
- </div><!-- #post-## -->
- <?php comments_template( '', true ); ?>
- <?php endwhile; // end of the loop. ?>
- <div id="coursepaneltop" style="margin-top:25px"> </div>
- <div id="coursepanel">
- <?php
- // Choose the icon to be displayed
- if (get_the_title()=="My Course 1") {$coursetypeimg = "courses_small.png";}
- if (get_the_title()=="My Course 2") {$coursetypeimg = "courses_small.png";}
- if (get_the_title()=="My Course 3") {$coursetypeimg = "courses_small.png";}
- if ($_GET["paged"]!="")
- {
- $offset = ($_GET["paged"] * 10)-10;
- }
- else
- {
- $offset=0;
- }
- $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
- // $courselist = new WP_Query( $querytxt );
- query_posts($querytxt);
- while ( have_posts() ) : the_post();
- $thumburl = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),'');
- $img = $thumburl[0];
- ?>
- <!-- start of a course box -->
- <div class="coursebox">
- <div class="courseimage"><img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo $img ?>&w=150&h=100&zc=1" /></div>
- <div class="coursetypeicon"><img src="<?php bloginfo('template_directory'); ?>/images/coursetypes/<?php echo $coursetypeimg ?>" width="27" height="27" /></div>
- <div class="coursetitle">
- <?php /*?><?php echo $p->post_title; ?><?php */?>
- <h2 class="entry-title"><a href="<?php echo get_permalink($post->ID) ?>" class=""><?php echo $post->post_title; ?></a></h2>
- </div>
- <div class="coursedetails">
- <div class="coursetext">
- <?php echo custom_get_the_excerpt($post->ID,true,50); ?>
- </div>
- <div class="courseaction" style="display:inline-block;float:left;margin-top:11px;">
- <a class="greybutton" href="<?php echo get_permalink($post->ID) ?>" title="<?php echo $post->post_title; ?> - Read More">More Info</a>
- </div>
- <div style="display:inline-block;float:left;">
- <!-- Custom field for Product ID-->
- <?php $values = get_post_custom_values('Product_ID',$post->ID);
- if ($values){
- ?>
- <?php echo get_button_code_for_product($values[0]); ?>
- <?php } else { ?>
- <p></p>
- <?php } ?>
- <!-- End Custom field for Product ID-->
- </div>
- </div>
- </div>
- <!-- end coursebox -->
- <div style="clear:both;"></div>
- <?php
- endwhile;
- //} // end of the loop.
- ?>
- </div><!-- coursepanel -->
- <?php /* Display navigation to next/previous pages when applicable */ ?>
- <?php if ( $wp_query->max_num_pages > 1 ) { ?>
- Page <?php echo $paged; ?> of <?php echo $wp_query->max_num_pages; ?>
- <?php for ($x=1; $x<=$wp_query->max_num_pages;$x++) {
- if($x==$paged)
- {
- $highlight="background-color:#444;color:#fff;";
- }
- else
- {
- $highlight="";
- }
- 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>';
- } ?>
- <!-- #nav-above -->
- <?php }//endif; ?>
- </div><!-- #content -->
- </div><!-- #container -->
- <?php get_sidebar('courses'); ?>
- <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement