Reputation: 662
I am using Twitter Bootstrap 3 and the Roots Theme.
i have a page called 'portfolio' that displays 6 portfolio items out of a total of 15,
I am using the following code:
/proman/assets/img/code011.jpg" alt="Folio Feature Image">
<!-- Add the pagination functions here. -->
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$query_recents = new WP_Query ( array( 'post_type' => 'portfolio', 'posts_per_page' => 3, 'paged' => $paged ) );
if ( $query_recents->have_posts() ):
?>
<!-- Start of the main loop. -->
<?php while ( $query_recents->have_posts() ) : $query_recents->the_post(); ?>
<div class="col-sm-4">
<!-- the rest of your theme's main loop -->
<?php get_template_part('templates/folio', get_post_format()); ?>
</div>
<?php endwhile; ?>
<!-- End of the main loop -->
<!-- Add the pagination functions here. -->
<div class="nav-previous alignleft"><?php next_posts_link( 'Older posts' ); ?></div>
<div class="nav-next alignright"><?php previous_posts_link( 'Newer posts' ); ?></div>
<?php else : ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
but nothing displays at all. I have looked at the codex as I was told this doesnt work for single page templates , Ive tried all kinds of varieties but nothing will display.
This has worked for me previously in a none bootstrap environment, Im not sure what I need to do.
would appreciate if anyone has an answer.
Upvotes: 0
Views: 327
Reputation: 147
I'm also using roots and bootstrap 3 with a portfolio while integrating the .thumbnail component.
check here: http://calebserna.com/portfolio/
It's working great. My solution was to create a category 'portfolio' then edit 'templates/content.php'.
<?php if(is_category('192')) : ?>
<div
<?php post_class('col-xs-6 col-md-3'); ?> >
<!-- bootstrap 3 thumbnails component -->
<div class="thumbnail">
<?php if ( has_post_thumbnail() ) { ?>
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail('bootstrap_portfolio_thumb'); ?>
</a>
<?php } ?>
<div class="caption">
<?php the_title(); ?>
</div>
</div>
</div>
<?php else : ?>
<?php
//the default content loop below
then edit config.php so a sidebar does not appear in category 'portfolio'.
if you really want to use a custom page with wp_query try inserting the defaul roots paging code in your template
//index.php
<?php if ($wp_query->max_num_pages > 1) : ?>
<nav class="post-nav">
<ul class="pager">
<li class="previous"><?php next_posts_link(__('← Older posts', 'roots')); ?></li>
<li class="next"><?php previous_posts_link(__('Newer posts →', 'roots')); ?></li>
</ul>
</nav>
<?php endif; ?>
Upvotes: 1
Reputation: 2306
Do you have your variable $paged
defined?
If not, add above your code
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
Upvotes: 2