… and yes… I made sure I was saving permalinks. 🙂
see if this helps:
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$loop = new WP_Query( array( 'post_type' => 'web', 'posts_per_page' => 1, 'paged' => $paged ) ); ?>
I did this…
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$loop = new WP_Query( array( 'post_type' => 'web', 'posts_per_page' => 1, 'paged' => $paged ) ); ?>
<?php if ( $loop->have_posts() ) : ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="portfolio-item">
<div class="portfolio-thumb"><a href="<?php the_permalink() ?>" rel="bookmark" title="Portfolio item: <?php the_title_attribute(); ?>"><?php the_post_thumbnail('portfolio-thumb'); ?></a></div>
<h4 class="portfolio-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Portfolio item: <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h4>
</div>
<?php endwhile; ?>
<?php wp_pagenavi( array( 'query' => $loop ) ); ?>
<?php wp_reset_postdata(); // reset the query ?>
<?php endif; ?>
then saved permalinks…. no go.
🙁
try first to see if pagination is working with next_posts_link and previous posts link In stead of wp_pagenavi pagination.
Interesting… I put them right next to the wp_pagenavi
(which is working – i think), and I get nothing. I even put a comma between the two… all I see is the comma.
from twentyten:
<div id="nav-below" class="navigation">
<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentyten' ) ); ?></div>
<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentyten' ) ); ?></div>
</div><!-- #nav-below -->
try it with this.
You don’t see any links? Did you put them in the right template file? do you have more than one cpt “web” Post published. is your template file archive-web.php? Do you only see cpt “web” Posts on this page?
Here’s the loop now….
[Code moderated as per the Forum Rules. Please use the pastebin]
here’s a link.
try registering this way: example
and put this in stead of the html <body>
tag so we can see what template file is being used and more:
<body <?php body_class($class); ?>>
Man oh man… you got it working!!!
A few things…
1. The slug is set to true, so “websites” is now a working url on my site along w/ the “portfolio/web”. The loop for register_post_type('web',$args);
works on both pages. This is good to know, but leads me to #2 on my list.
2. There is no “slug” (I know it’s a rewrite array) and I need it “portfolio/web”. I tried changing it and I get the 404 when the select the 2nd page.
3. When I implemented the registration that you gave me, it only produces the wp_pagenavi on the 1st page. The twentyten nav and wp_pagenavi appear on the 2nd page. Odd.
4. I did implement the body_class
. Thank you for that.
Link.
Thoughts?
Thank you so much for everything thus far.
PS. Is it wishful thinking that the WP would understand “parent/child” permalinks for CPTs with the currect released build (3.1)?
use this for the rewriting:
'rewrite' => array('slug' => 'portfolio/web'),
change this in your custom post archive template:
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$loop = new WP_Query( array( 'post_type' => 'web', 'posts_per_page' => 1, 'paged' => $paged ) ); ?>
<?php if ( $loop->have_posts() ) : ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
into a normal loop:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
and put this in your theme’s functions.php:
function my_custom_posts_per_page( &$q ) {
if ( $q->is_archive ) // any archive
if($q->query_vars['post_type'] == 'web'){ //custom post type "web" archive
$q->set( 'posts_per_page', 1 );
}
return $q;
}
add_filter('parse_query', 'my_custom_posts_per_page');
and re-save your permalink structure.
your permalinks will be
archive: http://www.capichedesignstudio.com/portfolio/web/
single posts: http://www.capichedesignstudio.com/portfolio/web/asfasf/
You’re amazing.
It works. 100%. Perfect.
Can you explain the function? Please?