Skip to content

Instantly share code, notes, and snippets.

@nicholasohrn
Forked from anonymous/gist:1447077
Created December 8, 2011 21:25
Show Gist options
  • Save nicholasohrn/1448671 to your computer and use it in GitHub Desktop.
Save nicholasohrn/1448671 to your computer and use it in GitHub Desktop.
Custom Query - Pagination Doesn't Work
<?php
/*
Template Name: Fuel Landing Page
*/
get_header();
$fuel_options = get_option('fuel_theme_options');
?>
<div id="pageWrap">
<h1 class="pageTitle alt_font fademe"><span>Fuel</span> Network</h1>
<?php include(TEMPLATEPATH."/left-sidebar.php"); ?>
<div id="page-<?php the_ID(); ?>" <?php post_class('theContent fademe box col'); ?>>
<?php the_content(); ?>
<div class="clear"></div>
</div> <!-- //.theContent -->
<?php if(!empty($fuel_options) ) { ?>
<div class="clear"></div>
<div class="stats box alt_font fademe">
<div class="blue statsTitle"><?php echo $fuel_options['fuelStatsTitle']; ?></div>
<?php landingStats($fuel_options, 'fuel'); ?>
<div class="clear"></div>
</div> <!-- //.stats -->
<?php } ?>
<div class="clear"></div>
<div class="infographics box fademe">
<a id="prevGraphic"></a>
<a id="nextGraphic"></a>
<div class="slides">
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Fuel Landing Page') ) : ?>
<?php endif; ?>
</div>
<div class="clear"></div>
</div>
<div id="page">
<?php
$queryCategory = get_category_by_slug( 'fuel_network' );
global $paged; // or $paged = get_query_var('paged'), depends on what exactly you're looking for.
$my_custom_query = new WP_Query(array('cat' => $queryCategory, 'posts_per_page' => 6, 'paged' => $paged));
while ($my_custom_query->have_posts()) : $my_custom_query->the_post();
$title = get_the_title();
if(strlen($title) > 45) {
$title = preg_replace('/\s+?(\S+)?$/', '', substr($title, 0, 45)) . "&hellip;";
}
?>
<div class="blogItem box">
<?php
//Get first child category of 'fuel_network'
foreach((get_the_category()) as $category) {
if($category->category_parent == $queryCategory->term_id) {
$itemCat = $category->cat_name;
break;
}
}
if(empty($itemCat))
$itemCat = $queryCategory->cat_name;
?>
<h2 class="gray alt_font"><?php echo $itemCat; ?></h2>
<h1><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php echo $title; ?></a></h1>
<?php the_excerpt(); ?>
<a href="<?php the_permalink() ?>" class="readmore">Keep Reading &raquo;</a>
</div>
<?php
//Clear out variable for next loop around
$itemCat = "";
endwhile;
?>
</div> <!-- // #page -->
<div class="postNavigation">
<div class="prevPosts"><p><?php previous_posts_link('&laquo; Newer Posts') ?></p></div>
<div class="nextPosts"><p><?php next_posts_link('Older Posts &raquo;') ?></p></div>
</div>
<div class="clear"></div>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment