Skip to content

Instantly share code, notes, and snippets.

@inxilpro
Created November 3, 2010 22:22
Show Gist options
  • Save inxilpro/661819 to your computer and use it in GitHub Desktop.
Save inxilpro/661819 to your computer and use it in GitHub Desktop.
Modified portfolio to allow for page content
<?php
/*
Template Name: Portfolio
*/
?>
<?php global $woo_options; ?>
<?php get_header(); ?>
<!-- Breadcrumb & Tags -->
<?php if ( $woo_options['woo_portfolio_tags'] ) { ?>
<div id="breadcrumb">
<div class="col-full">
<div class="fl">
<?php
$tags = explode(',',$woo_options['woo_portfolio_tags']); // Tags to be shown
foreach ($tags as $tag){
$tag = trim($tag);
$displaytag = $tag;
$tag = str_replace (" ", "-", $tag);
$tag = str_replace ("/", "-", $tag);
$tag = strtolower ( $tag );
$link_tags[] = '<a href="#" rel="'.$tag.'">'.$displaytag.'</a>';
}
$new_tags = implode(' ',$link_tags);
?>
<span class="port-cat"><?php _e('Select a category:', 'woothemes'); ?>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" rel="all"><?php _e('All','woothemes'); ?></a>&nbsp;<?php echo $new_tags; ?></span>
</div>
<a class="subscribe fr" href="<?php if ( $woo_options['woo_feed_url'] <> "" ) { echo $woo_options['woo_feed_url']; } else { echo bloginfo('url') . "/?feed=rss2"; } ?>">
<img src="<?php bloginfo('template_directory'); ?>/images/ico-rss.png" alt="Subscribe" class="rss" />
</a>
<div class="<?php if ( $bc == "true" ) echo 'fr'; else echo 'fl'; ?>">
<span class="fr catrss"><a class="subscribe fr" href="<?php if ( $woo_options['woo_feed_url'] <> "" ) { echo $woo_options['woo_feed_url']; } else { echo get_bloginfo_rss('rss2_url'); } ?>"></a></span>
</div>
</div>
</div>
<?php } else { ?>
<?php woo_crumbs(); ?>
<?php } ?>
<!-- /Breadcrumb & Tags -->
</div><!-- /#top -->
<div id="content">
<div class="col-full">
<div id="main" class="fullwidth">
<?php if (have_posts()) : $count = 0; ?>
<?php while (have_posts()) : the_post(); $count++; ?>
<div class="post">
<h1 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1>
<div class="entry">
<?php the_content(); ?>
</div><!-- /.entry -->
</div><!-- /.post -->
<?php endwhile; ?>
<?php endif; ?>
</div><!-- /#main -->
<div id="portfolio">
<?php
$portfolio_query = new WP_Query();
$portfolio_query->query('post_type=portfolio&order=DESC&posts_per_page=20');
if ($portfolio_query->have_posts()) : while ($portfolio_query->have_posts()) : $portfolio_query->the_post(); $counter++;
?>
<?php
// Portfolio tags class
$porttag = "";
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
$tag = $tag->name;
$tag = str_replace (" ", "-", $tag);
$tag = str_replace ("/", "-", $tag);
$tag = strtolower ( $tag );
$porttag .= $tag . ' ';
}
}
?>
<!-- Post Starts -->
<div class="post block fl <?php echo $porttag; ?>">
<?php
// Check if there is a gallery in post
$gallery = woo_get_post_images();
if ( $gallery ) {
// Get first uploaded image in gallery
$large = $gallery[0]['url'];
$caption = $gallery[0]['caption'];
} else {
// Grab large portfolio image
$large = get_post_meta($post->ID, 'portfolio-large', $single = true);
}
// Setup lightbox if activated
if ( $woo_options['woo_portfolio_lightbox'] == "true" )
$rel = 'rel="prettyPhoto['. $post->ID .']"'
?>
<a <?php echo $rel; ?> title="<?php echo $caption; ?>" href="<?php echo $large; ?>" class="thumb">
<?php
if ( $woo_options['woo_portfolio_resize'] ) {
woo_image('key=portfolio&width=440&height=210&class=portfolio-img&link=img');
} else { ?>
<img class="portfolio-img" src="<?php echo get_post_meta($post->ID, 'portfolio', $single = true); ?>" alt="" />
<?php } ?>
</a>
<?php
// Output image gallery for lightbox
if ( $gallery ) {
foreach ( array_slice($gallery, 1) as $img => $attachment ) {
echo '<a '.$rel.' title="'.$attachment['caption'].'" href="'.$attachment['url'].'" class="gallery-image"></a>';
}
}
?>
<h2 class="title"><?php the_title(); ?></h2>
<div class="entry">
<?php the_content(); ?>
</div><!-- /.entry -->
</div><!-- /.post -->
<?php endwhile; else: ?>
<div class="post">
<p class="note">You need to setup the <strong>Portfolio</strong> options and select a category for your portfolio posts.</p>
</div><!-- /.post -->
<?php endif; ?>
<div class="fix"></div>
<div class="more_entries">
<?php if (function_exists('wp_pagenavi')) wp_pagenavi(); else { ?>
<div class="fl"><?php previous_posts_link(__('&laquo; Newer Entries ', 'woothemes')) ?></div>
<div class="fr"><?php next_posts_link(__(' Older Entries &raquo;', 'woothemes')) ?></div>
<br class="fix" />
<?php } ?>
</div>
</div><!-- /#portfolio -->
</div><!-- /.col-full -->
</div><!-- /#content -->
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment