Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Pagination error with custom posts categories WordPress

  • SOLVED

Hi all,

I have created a custom post called "portfolio categories" and they are hierarchal. I am pulling out these posts using the taxonomy template, ie my filename is "taxonomy-portfolio_cats.php". I am also using wp-pagenavi to create the pagination.

There are no problems with pagination with any other loop in the theme.

Here's the code



<?php $temp = $wp_query; $wp_query= null;
$wp_query = new WP_Query('posts_per_page=12&post_type=portfolio_posts&portfolio_cats=' . $taxonomy_single . '&paged=' . $paged);
while ($wp_query->have_posts()) : $wp_query->the_post();
$portfolio_type = get_post_meta($post->ID, 'p_type', $single = true);
$portfolio_video = get_post_meta($post->ID, 'pv_type', $single = true);
$image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id,'original');
$image_url = $image_url[0];

?>

<div class="portfolio_item_4_col">

*** DO SOMETHING ****

</div><!-- /portfolio_item_4_col -->

<?php endwhile; ?>

<br class="clear" />

<?php include('wp-pagenavi.php'); if(function_exists('wp_pagenavi')) { wp_pagenavi(); } $wp_query = null; $wp_query = $temp;?>





I read in a previous wpquestions post that I need to set the posts per page in the WP control panel to the same number as the loop. I did that and it changed nothing.

Any help greatly appreciated.

Ollie

<strong>EDIT: Here's the url

http://www.olliemccarthy.com/themes/silverpoint_preview/?portfolio_cats=images

Scroll to the bottom of the page and click on "2".</strong>

<strong>EDIT2: Here's the code where I setup the custom posts</strong>




<?php


// Create Custom Post Types
add_action( 'init', 'create_my_post_types' );
function create_my_post_types() {
register_post_type( 'nivo_posts',
array(
'labels' => array(
'name' => __( 'Featured Posts Nivo Page' ),
'singular_name' => __( 'Featured Posts Nivo Page' )
),
'public' => true,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpts')
)
);
register_post_type( 'business_posts',
array(
'labels' => array(
'name' => __( 'Featured Posts Business Page' ),
'singular_name' => __( 'Featured Posts Business Page' )
),
'public' => true,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpts')
)
);
register_post_type( 'portfolio_posts',
array(
'labels' => array(
'name' => __( 'Portfolio Items' ),
'singular_name' => __( 'Portfolio Items' )
),
'public' => true,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpts')

)
);
register_post_type( 'testimonials',
array(
'labels' => array(
'name' => __( 'Testimonials' ),
'singular_name' => __( 'Testimonials' )
),
'public' => true,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpts')
)
);
}

//Adds Portfolio Taxonomy (categories
function post_type_portfolio() {

register_post_type('portfolio_posts',
array(
'labels' => array(
'name' => __( 'Portfolio Items' ),
'singular_name' => __( 'Portfolio Items' ),
'add_new' => __( 'Add New' ),
'add_new_item' => __( 'Add New Portfolio Item' ),
'edit' => __( 'Edit' ),
'edit_item' => __( 'Edit Portfolio Item' ),
'new_item' => __( 'New Portfolio Item' ),
'view' => __( 'View Portfolio Item' ),
'view_item' => __( 'View Portfolio Item' ),
'search_items' => __( 'Search Portfolio Item' ),
'not_found' => __( 'No Portfolio Items found' ),
'not_found_in_trash' => __( 'No Portfolio Items found in Trash' ),
'parent' => __( 'Parent Portfolio Items' ),
),
'public' => true,
'show_ui' => true,
'exclude_from_search' => true,
'hierarchical' => true,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpts' ),
'query_var' => true
)
);
}
add_action('init', 'post_type_portfolio');

add_action( 'init', 'create_portfolio_taxonomies', 0 );

function create_portfolio_taxonomies()
{
// Add new taxonomy, make it hierarchical (like categories)
$labels = array(
'name' => _x( 'Portfolio Categories', 'taxonomy general name' ),
'singular_name' => _x( 'Portfolio Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Portfolio Categories' ),
'popular_items' => __( 'Popular Portfolio Categories' ),
'all_items' => __( 'All Portfolio Categories' ),
'parent_item' => __( 'Parent Portfolio Category' ),
'parent_item_colon' => __( 'Parent Portfolio Category:' ),
'edit_item' => __( 'Edit Portfolio Category' ),
'update_item' => __( 'Update Portfolio Category' ),
'add_new_item' => __( 'Add New Portfolio Category' ),
'new_item_name' => __( 'New Portfolio Category Name' ),
);
register_taxonomy('portfolio_cats',array('portfolio_posts'), array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'portfolio' ),
));
}


// Adds Metabox to Portfolio Items
add_action("admin_init", "p_type_innit");
add_action('save_post', 'save_p_type');
function p_type_innit(){
add_meta_box("Portfolio_Type", "Portfolio Type", "meta_options_p", "portfolio_posts", "normal", "high");
}
function meta_options_p(){
global $post;
$custom_portfolio_type = get_post_custom($post->ID);
$portfolio_type = $custom_portfolio_type["p_type"][0];
$portfolio_video = $custom_portfolio_type["pv_type"][0];
$galleria1 = $custom_portfolio_type["pg_type1"][0];
$galleria2 = $custom_portfolio_type["pg_type2"][0];
$galleria3 = $custom_portfolio_type["pg_type3"][0];
$galleria4 = $custom_portfolio_type["pg_type4"][0];
$galleria5 = $custom_portfolio_type["pg_type5"][0];
$galleria6 = $custom_portfolio_type["pg_type6"][0];
$galleria7 = $custom_portfolio_type["pg_type7"][0];
$galleria8 = $custom_portfolio_type["pg_type8"][0];

?>
<p><label>Options - "video" | "image" | "galleria" | "page" : </label><input style="width:50%; border:1px solid #e3e3e3; float:right;" name="p_type" value="<?php echo $portfolio_type; ?>" /></p>
<br style="clear:both;" />

<p><label>Video URL (Paste URL if using video)</label><input style="width:50%; border:1px solid #e3e3e3; float:right;" name="pv_type" value="<?php echo $portfolio_video; ?>" /></p>
<br style="clear:both;" />

<p><label>Galleria Image Url - 1</label><input style="width:50%; border:1px solid #e3e3e3; float:right;" name="pg_type1" value="<?php echo $galleria1; ?>" /></p>
<br style="clear:both;" />
<p><label>Galleria Image Url - 2</label><input style="width:50%; border:1px solid #e3e3e3; float:right;" name="pg_type2" value="<?php echo $galleria2; ?>" /></p>
<br style="clear:both;" />
<p><label>Galleria Image Url - 3</label><input style="width:50%; border:1px solid #e3e3e3; float:right;" name="pg_type3" value="<?php echo $galleria3; ?>" /></p>
<br style="clear:both;" />
<p><label>Galleria Image Url - 4</label><input style="width:50%; border:1px solid #e3e3e3; float:right;" name="pg_type4" value="<?php echo $galleria4; ?>" /></p>
<br style="clear:both;" />
<p><label>Galleria Image Url - 5</label><input style="width:50%; border:1px solid #e3e3e3; float:right;" name="pg_type5" value="<?php echo $galleria5; ?>" /></p>
<br style="clear:both;" />
<p><label>Galleria Image Url - 6</label><input style="width:50%; border:1px solid #e3e3e3; float:right;" name="pg_type6" value="<?php echo $galleria6; ?>" /></p>
<br style="clear:both;" />
<p><label>Galleria Image Url - 7</label><input style="width:50%; border:1px solid #e3e3e3; float:right;" name="pg_type7" value="<?php echo $galleria7; ?>" /></p>
<br style="clear:both;" />
<p><label>Galleria Image Url - 8</label><input style="width:50%; border:1px solid #e3e3e3; float:right;" name="pg_type8" value="<?php echo $galleria8; ?>" /></p>
<br style="clear:both;" />
<?php
}
function save_p_type(){
global $post;
update_post_meta($post->ID, "p_type", $_POST["p_type"]);
update_post_meta($post->ID, "pv_type", $_POST["pv_type"]);
update_post_meta($post->ID, "pg_type1", $_POST["pg_type1"]);
update_post_meta($post->ID, "pg_type2", $_POST["pg_type2"]);
update_post_meta($post->ID, "pg_type3", $_POST["pg_type3"]);
update_post_meta($post->ID, "pg_type4", $_POST["pg_type4"]);
update_post_meta($post->ID, "pg_type5", $_POST["pg_type5"]);
update_post_meta($post->ID, "pg_type6", $_POST["pg_type6"]);
update_post_meta($post->ID, "pg_type7", $_POST["pg_type7"]);
update_post_meta($post->ID, "pg_type8", $_POST["pg_type8"]);

}


// Adds Metabox to Featured Posts Items
add_action("admin_init", "f_type_innit");
add_action('save_post', 'save_f_type');
function f_type_innit(){
add_meta_box("Featured Post Options", "Featured Post Options", "meta_options_f", "nivo_posts", "normal", "high");
}
function meta_options_f(){
global $post;
$custom_nivo_posts = get_post_custom($post->ID);
$nivo_anchor = $custom_nivo_posts["nivo_anchor"][0];
$nivo_description = $custom_nivo_posts["nivo_description"][0];

?>
<p><label>Anchor (Paste in URL where you want to point to) : </label><input style="width:50%; border:1px solid #e3e3e3; float:right;" name="nivo_anchor" value="<?php echo $nivo_anchor; ?>" /></p>
<br style="clear:both;" />

<p><label>Description (Paste in description if you want) : </label><input style="width:50%; border:1px solid #e3e3e3; float:right;" name="nivo_description" value="<?php echo $nivo_description; ?>" /></p>
<br style="clear:both;" />

<?php
}
function save_f_type(){
global $post;
update_post_meta($post->ID, "nivo_anchor", $_POST["nivo_anchor"]);
update_post_meta($post->ID, "nivo_description", $_POST["nivo_description"]);

}



// Adds Metabox to Testimonials
add_action("admin_init", "t_type_innit");
add_action('save_post', 'save_t_type');
function t_type_innit(){
add_meta_box("Testimonial Options", "Testimonial Options", "meta_options_t", "testimonials", "normal", "high");
}
function meta_options_t(){
global $post;
$custom_testimonials = get_post_custom($post->ID);
$testimonial_name = $custom_testimonials["testimonial_name"][0];
$testimonial_title = $custom_testimonials["testimonial_title"][0];
$testimonial_portrait = $custom_testimonials["testimonial_portrait"][0];

?>
<p><label>Testimonial Name : </label><input style="width:50%; border:1px solid #e3e3e3; float:right;" name="testimonial_name" value="<?php echo $testimonial_name; ?>" /></p>
<br style="clear:both;" />

<p><label>Testimonial Company/Title : </label><input style="width:50%; border:1px solid #e3e3e3; float:right;" name="testimonial_title" value="<?php echo $testimonial_title; ?>" /></p>
<br style="clear:both;" />

<p><label>Testimonial Portrait Photo URL : </label><input style="width:50%; border:1px solid #e3e3e3; float:right;" name="testimonial_portrait" value="<?php echo $testimonial_portrait; ?>" /></p>
<br style="clear:both;" />

<?php
}
function save_t_type(){
global $post;
update_post_meta($post->ID, "testimonial_name", $_POST["testimonial_name"]);
update_post_meta($post->ID, "testimonial_title", $_POST["testimonial_title"]);
update_post_meta($post->ID, "testimonial_portrait", $_POST["testimonial_portrait"]);

}




// Adds Metabox to Featured Business Posts Items
add_action("admin_init", "x_type_innit");
add_action('save_post', 'save_x_type');
function x_type_innit(){
add_meta_box("Featured Post Options", "Featured Post Options", "meta_options_x", "business_posts", "normal", "high");
}
function meta_options_x(){
global $post;
$custom_business_posts = get_post_custom($post->ID);
$business_anchor = $custom_business_posts["business_anchor"][0];
$vimeo_link = $custom_business_posts["vimeo_link"][0];

?>
<p><label>Anchor (Paste in URL where you want to point to) : </label><input style="width:50%; border:1px solid #e3e3e3; float:right;" name="business_anchor" value="<?php echo $business_anchor; ?>" /></p>
<br style="clear:both;" />
<p><label>Vimeo Embed Code : </label><textarea style="width:50%; border:1px solid #e3e3e3; float:right;" name="vimeo_link"><?php echo $vimeo_link; ?></textarea></p>
<br style="clear:both;" />

<?php
}
function save_x_type(){
global $post;
update_post_meta($post->ID, "business_anchor", $_POST["business_anchor"]);
update_post_meta($post->ID, "vimeo_link", $_POST["vimeo_link"]);

}





?>

Answers (8)

2011-01-18

Jens Filipsson answers:

Hey there!
I´ve tried to modify your code a little, how does this work for you?

<?php
$loop = new WP_Query( array( 'paged' => $paged, 'portfolio_cats' => $taxonomy_single, 'post_type' => 'portfolio_posts', 'posts_per_page' => 12 ) );

while ( $loop->have_posts() ) : $loop->the_post();

$portfolio_type = get_post_meta($post->ID, 'p_type', $single = true);

$portfolio_video = get_post_meta($post->ID, 'pv_type', $single = true);

$image_id = get_post_thumbnail_id();

$image_url = wp_get_attachment_image_src($image_id,'original');

$image_url = $image_url[0];

?>


<div class="portfolio_item_4_col">

*** DO SOMETHING ****

</div><!-- /portfolio_item_4_col -->

<?php endwhile; ?>

<br class="clear" />

<?php include('wp-pagenavi.php'); if(function_exists('wp_pagenavi')) { wp_pagenavi(); } $wp_query = null; $wp_query = $temp;?>


Ollie McCarthy comments:

Unfortunately that didn't work.


Jens Filipsson comments:

There might be a simpler solution to this.

It is like this: You cn't have a normal wordpress page and a custom post type with the same name. This will give problems with the permalinks and give you a 404. If this is your problem, you should:

Change the name of the page that lists the custom post types and you should be fine. If this is your problem of course! :)


Ollie McCarthy comments:

The page is not really a page (i know that sounds odd). It is actually a custom post category added to the WP3 menu.


Jens Filipsson comments:

OK, here is something I found at the wordpress forums. Try to put this in your <strong>functions.php</strong> file:

define('PER_PAGE_DEFAULT', 12);
function custom_query_posts(array $query = array())
{
global $wp_query;
wp_reset_query();

$paged = get_query_var('paged') ? get_query_var('paged') : 1;

$defaults = array(
'post_type' => 'portfolio_posts',
'portfolio_cats' => $taxonomy_single,
'paged' => $paged,
'posts_per_page' => PER_PAGE_DEFAULT
);
$query += $defaults;

$wp_query = new WP_Query($query);
}


And then replace the code you already have with this:

<?php custom_query_posts()?>
<?php while (have_posts()) : the_post();

$portfolio_type = get_post_meta($post->ID, 'p_type', $single = true);
$portfolio_video = get_post_meta($post->ID, 'pv_type', $single = true);
$image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id,'original');
$image_url = $image_url[0];
?>

<div class="portfolio_item_4_col">

*** DO SOMETHING ****

</div><!-- /portfolio_item_4_col -->

<?php endwhile; ?>

<br class="clear" />

<?php include('wp-pagenavi.php'); if(function_exists('wp_pagenavi')) { wp_pagenavi(); } $wp_query = null; $wp_query = $temp;?>


Ollie McCarthy comments:

I tried that and it didn't work.


Jens Filipsson comments:

Ok, my last attempt! I still think it has to do with the page slug somehow, as explained here:

[[LINK href="http://minimalite.com/2010/09/wordpress-hacks/pagination-for-custom-post-types-in-wordpress/"]][[/LINK]]

So add something like this to your functions.php file, in the block of code that sets up your custom post types!

'rewrite' => array('slug' => 'news/article'),

Choose a slug that suits you, but dont use the slug <em>images</em>.


Jens Filipsson comments:

Sorry, the link got striped somehow! Here is the page where it's explained:

http://minimalite.com/2010/09/wordpress-hacks/pagination-for-custom-post-types-in-wordpress/


Ollie McCarthy comments:

That didn't work either I'm afraid.


Jens Filipsson comments:

It would be great if you could provide some more info, like how you set up your custom post types, the complete code that you use fetching them etc... Otherwise I think it will be hard to help you, at least for me, I can't think of much else to do at the moment! Sorry!


Ollie McCarthy comments:

Ok I will post the code where I setup the original custom post. It ain't pretty so please don't judge me ;)


Jens Filipsson comments:

Just one thing, in the post from David down here, you should change it to this (there was another error with the code that he didn't change, don't know if this will help either, but worth a try... It's still his solution, so if it works, he should have the money.)

<?php $args=array('paged'=>$paged, 'posts_per_page'=>5, 'post_type'=>'portfolio_posts', 'portfolio_cats' =>$taxonomy_single, 'offset' => $offset); ?>


Ollie McCarthy comments:

I tried this an still no joy. Did the setup of the custom posts look ok?

2011-01-18

Rashad Aliyev answers:

Hello,

Give your site url please.

try to rest your query at last.

<?php
wp_reset_query();
?>


Ollie McCarthy comments:

Just put up the URL. As you can tell I'm more a designer than developer :)


Rashad Aliyev comments:

Change your site permalinks to /%postname%/ and test it again.


Ollie McCarthy comments:

I can't change the permalinks unfortunately.

It is a commercial theme and I have no idea what permalink structure my potential customers will use.


Rashad Aliyev comments:

Just change it for testing.


Rashad Aliyev comments:

It was worked yesterday, I saw. why you edited it again?


Ollie McCarthy comments:

When was it working? you mean the permalinks or the paging? Neither have worked so far!

2011-01-18

juan manuel incaurgarat answers:

try this

<div class="pagination">
<span class="next"><?php next_posts_link(__('Next &raquo;', 0)) ?></span>
<span class="previous"><?php previous_posts_link(__('&laquo; Previous', 0)) ?></span>
</div>


Ollie McCarthy comments:

I'm trying to get the posts to page eg 1, 2, 3, etc. It would probably work but is a little different to what I'm trying to do. Thanks for taking the time to answer.

2011-01-18

Ivaylo Draganov answers:

Why are you messing with the query? If you're using the taxonomy template there's no need to create a new query object. Simply use a regular loop:

if(have_posts()) : while(have_posts()) : the_post();

// do stuff with posts

endwhile; endif;



EDIT:

Or check out this topic in the WP Forum:
[[LINK href="http://wordpress.org/support/topic/pagination-with-custom-post-type-getting-a-404"]]http://wordpress.org/support/topic/pagination-with-custom-post-type-getting-a-404[[/LINK]]

or maybe this one:
[[LINK href="http://wordpress.org/support/topic/pagination-with-custom-post-type-listing?replies=23#post-1637753"]]http://wordpress.org/support/topic/pagination-with-custom-post-type-listing?replies=23#post-1637753[[/LINK]]

Seems like Utkarsh is on the right track :)

2011-01-18

Utkarsh Kukreti answers:

Try adding this at the beginning.

$paged = get_query_var( 'page' ) ? get_query_var( 'page' ) : 1;


Ollie McCarthy comments:

I tried that but it didn't work.

2011-01-18

Erez S answers:

Try this:

<?php $temp = $wp_query; $wp_query= null;
$paged = get_query_var( 'page' ) ? get_query_var( 'page' ) : 1;
$wp_query = new WP_Query('posts_per_page=12&post_type=portfolio_posts&portfolio_cats=' . $taxonomy_single . '&paged=' . $paged);
while ($wp_query->have_posts()) : $wp_query->the_post();
$portfolio_type = get_post_meta($post->ID, 'p_type', $single = true);
$portfolio_video = get_post_meta($post->ID, 'pv_type', $single = true);
$image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id,'original');
$image_url = $image_url[0];
?>
<div class="portfolio_item_4_col">
*** DO SOMETHING ****
</div><!-- /portfolio_item_4_col -->
<?php endwhile; ?>
<br class="clear" />
<?php include('wp-pagenavi.php'); if(function_exists('wp_pagenavi')) { wp_pagenavi(); } $wp_query = null; $wp_query = $temp;?>


And if not working, try this:

<?php $temp = $wp_query; $wp_query= null;
$paged = get_query_var( 'page' ) ? get_query_var( 'page' ) : 1;
query_posts('posts_per_page=12&post_type=portfolio_posts&portfolio_cats=' . $taxonomy_single . '&paged=' . $paged);
while (have_posts()) : the_post();
$portfolio_type = get_post_meta($post->ID, 'p_type', $single = true);
$portfolio_video = get_post_meta($post->ID, 'pv_type', $single = true);
$image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id,'original');
$image_url = $image_url[0];
?>
<div class="portfolio_item_4_col">
*** DO SOMETHING ****
</div><!-- /portfolio_item_4_col -->
<?php endwhile; ?>
<br class="clear" />
<?php include('wp-pagenavi.php'); if(function_exists('wp_pagenavi')) { wp_pagenavi(); } $wp_query = null; $wp_query = $temp; wp_reset_query(); ?>


Ollie McCarthy comments:

Unfortunately both of those don't work.

2011-01-18

David answers:

Ok first try with this not touching the wp-pagenavi until we get pagination to work



<?php $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; ?>
// current page times the amount you want to show per page
<?php $offset = ( 5 * $paged ) - 5; ?>
<?php $args=array(‘paged’=>$paged, 'posts_per_page'=>5, 'post_type'=>'portfolio_posts', portfolio_cats='$taxonomy_single, ', 'offset' => $offset); ?>
<?php query_posts($args); ?>

//The Loop
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); $portfolio_type = get_post_meta($post->ID, 'p_type', $single = true);

$portfolio_video = get_post_meta($post->ID, 'pv_type', $single = true);

$image_id = get_post_thumbnail_id();

$image_url = wp_get_attachment_image_src($image_id,'original');

$image_url = $image_url[0];

?>

<div class="portfolio_item_4_col">



*** DO SOMETHING ****



</div><!-- /portfolio_item_4_col -->

<?php endwhile; ?>

<br class="clear" />

<div class="pagination-links">
<span class="next"><?php next_posts_link(__('Next &raquo;', 0)) ?></span>
<span class="previous"><?php previous_posts_link(__('&laquo; Previous', 0)) ?></span>
</div>

<?php endif; ?>


Then if that works replace with this



<?php $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; ?>
// current page times the amount you want to show per page -chapeau Justin Tadlock
<?php $offset = ( 5 * $paged ) - 5; ?>
<?php $args=array(‘paged’=>$paged, 'posts_per_page'=>5, 'post_type'=>'portfolio_posts', portfolio_cats='$taxonomy_single, ', 'offset' => $offset); ?>
<?php query_posts($args); ?>

//The Loop
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); $portfolio_type = get_post_meta($post->ID, 'p_type', $single = true);

$portfolio_video = get_post_meta($post->ID, 'pv_type', $single = true);

$image_id = get_post_thumbnail_id();

$image_url = wp_get_attachment_image_src($image_id,'original');

$image_url = $image_url[0];

?>

<div class="portfolio_item_4_col">



*** DO SOMETHING ****



</div><!-- /portfolio_item_4_col -->

<?php endwhile; ?>

<br class="clear" />


<?php include('wp-pagenavi.php'); if(function_exists('wp_pagenavi')) { wp_pagenavi(); }; ?>

<?php endif; ?>


Which should do the trick for you


Ollie McCarthy comments:

It's saying there's an error on this line.



<?php $args=array(‘paged’=>$paged, 'posts_per_page'=>5, 'post_type'=>'portfolio_posts', portfolio_cats='$taxonomy_single, ', 'offset' => $offset); ?>


David comments:

Ok sorry typo, that should be <?php $args=array(‘paged’=>$paged, 'posts_per_page'=>5, 'post_type'=>'portfolio_posts', 'portfolio_cats' =>$taxonomy_single, 'offset' => $offset); ?>



Ollie McCarthy comments:

Sorry, that didn't work.


David comments:

I have this working on a test install... Can you visit your permalinnk settings in wp-admin and then try again please. This will force WP to flush the re-write settings, then try it again.. Thanks


Ollie McCarthy comments:

I think you could be onto something :)

I have tried setting up permalinks other than default and I'm getting the dreaded white 404 pages. I contacted my hosting company this morning and they said that the .htaccess file is enabled and should be working.

I pasted the rewrite rules from the WP codex and placed the file in the root folder of that WP installation but I am still getting the white 404s.

Any idea what's going on there?


David comments:

I have just spent an hour on this with your custom code duplicate on my local testing server and cannot duplicate this error you are getting...

Can you please turn back on your permalinks and set them to
/%category%/%postname%/

And try the first code with the typos corrected eg use the standard wordpress previous next post links

thanks


Ollie McCarthy comments:

Ok it sounds like you've sorted it. The only problem is that I cannot get the frigging permalinks to work. I have emailed my hosting company to try and figure out what's going on. Once it is sorted I will test the code asap.


Ollie McCarthy comments:

Ok I got to work on another install where permalinks work correctly and I have copied over the code you've posted. It is still giving 404s.

I pretty sure I followed everything. First get the permalinks functioning as you'd suggested. Next I changed the code and still no joy. I also change the rewrite in the custom post setup as someone else suggested. I even "flushed" the permalinks by going back and forth between pretty and default permalinks. No joy.


One thing I'd like to clarify. Have you got the parent level (and subsequent children) page to paginate or have you got a sub-category using the taxonomy-subcat.php template?

Can I have a look at your install? Just WP logins so I can look through the WP-editor. Maybe there's something I'm missing.

2011-01-20

Oleg Butuzov answers:

Unfortunately this woldn't work in this way (i mean usin custom queries + correct per paging). to make it workable custom query should run in parse query request.

---
update 16:03 - 21.01.2011

Unfortunately i can't answer you below cause this question is expired.
the pagination is generated from the $wp_query object based on per page number value and founded rows. course we have only one wp_query its generate the pagination based on custom query. but can't process it via non page embedded wp_query.


Ollie McCarthy comments:

Sorry I don't really understand as I am not really an expert on the inner workings of WP.

Would that mean that the custom posts wouldn't page at all. For example I setup a parent page where they do page. Here's the url

http://www.olliemccarthy.com/themes/silverpoint_preview/?page_id=27

I can't understand why it wouldn't work when you start drilling down into the sub-categories.

Please forgive any lack of knowledge in the above :)


Oleg Butuzov comments:

the difference betwean custom quesries and inner queries in a page the inner queries is parsed before templates runs... and if inner queries dosn't return any new row it will give 404 and will search for the 404 template and run it. same as all 404 struture (headers title tag $wp_query->is_404 etc).

what you need to do is change permanent urls to fin your needs or manualy (via filters change wp_query object) so your custom query become inner query.


Ollie McCarthy comments:

How come the pagination for the global listing of the custom posts works? Here's the link: http://www.olliemccarthy.com/themes/silverpoint_preview/?page_id=27

Is there some issue with the taxonomy template as opposed to the global customs posts template I create? Forgive my ignorance on the subject.