WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using a custom post type named fotograf. If it shows all photos in archive page, no problem. It finds photos in every page. But if I'm search a custom category in fotograf custom post type, then nothing found if paged>=2. Just finds the page 1.

You can test it in my web site. http://www.onurunwebsitesi.com

Click to Tümünü Göster (Show All), and click Diğer (Other) category and click pagination links at bottom. 2nd page and others not found.

My code:


<?php /** * Displays the Pagination in Custom loop * */?>
<?php get_header(); ?>
$temp = $wp_query; //save old query
$wp_query= null; //clear $wp_query
$aranan= $_GET['s']; 
$kategorim = intval($_GET['cat']);
$myterm = get_term( $kategorim, 'fgaleri' ); 
$myslug = $myterm->slug; ?>
<div id="content">
$rakam= 0;
//The query
$wp_query = new WP_Query();


$wp_query->query( array( 'post_type' =>'fotograf', 's' => $aranan, 'paged' => $paged, 'taxonomy' => 'fgaleri', 'fgaleri' => $myslug ) );
//The loop
<div id="FGaleri_2"><div id="FGaleri_Ic"><div id="FGaleriBaslik">Fotoğraf Galerisi 
<form action="<?php echo get_bloginfo('wpurl'); ?>" id="searchformfoto" method="get" name="searchform">
<?php $args = array( 'taxonomy' => 'fgaleri', 'show_option_none' => 'Kategori Seç ve Ara', 'hierarchical' => 1 ); wp_dropdown_categories($args); ?>
<div id="aramabolumufoto">
<input name="s" id="sfoto" type="text" value=""/>
<input type="hidden" name="post_type" value="fotograf" />
<input id="searchsubmitfoto" type="submit" value="Ara"/>
<div class="FGaleri_Ic_2"><?php while ($wp_query->have_posts()): $wp_query->the_post(); $rakam++; ?>
<div class="FGaleriItem2" style="<?php if ($rakam % 5 == 0 ) { ?>margin-right: 0px;<?php } ?>">
$termargs=array('orderby' => 'count', 'order' => 'desc');
$terms = wp_get_post_terms( $post->ID , 'fgaleri', $termargs );
$t = count($terms);
if ($t>0) { ?>
<div class="fkategori">
$c = 0;
foreach($terms as $term) {
if ($c==$t) 
echo '<a class="foto_kategori" href="'. home_url() . '/?cat=' . $term->term_id . '&post_type=fotograf&fgaleri=' . $term->slug . '" title="' . $term->name . '" ' . '>' . $term->name.'</a> ';
} ?>
<?php } ?>
<div class="ResimUst">
<?php if (has_post_thumbnail()) { ?>
<a href="<?php the_permalink() ?>">
<?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
$url2 = get_bloginfo('template_directory') . "/timthumb.php?src=" . $url . "&amp;w=100&amp;h=100&amp;zc=1"; ?>
<img src="<?php if(get_option('of_timthumb')=="true") { echo $url2; } else { echo $url; } ?>" alt="" title="" width="100" height="100" />
<?php } ?>
<div class="ResimAlt">
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
<?php endwhile; ?>
<div class="clearboth"></div>
<?php if(function_exists('wp_pagenavi') ) {     
wp_pagenavi(); //function call for plugin pagination( wp pagenavi plugin)
}else{ ?>     
<div id="navigasyon">
<span class="previous-entries">
<?php next_posts_link('« Daha Eski Fotoğraflar'); ?></span>
<span class="next-entries"><?php previous_posts_link('Daha Yeni Fotoğraflar »'); ?    ></span>
</div><?php } //endif
$wp_query = null; //Reset the normal query
$wp_query = $temp; //Restore the query
</div><?php get_sidebar(); ?></div><?php get_footer(); ?>
share|improve this question

In your query you pass 'paged' => $paged, but you never assign a value to $paged, so you are always seeing the first page of results. try defining it first:

$paged = (get_query_var('page')) ? get_query_var('page') : 1;
$wp_query->query( array( 'post_type' =>'fotograf', 's' => $aranan, 'paged' => $paged, 'taxonomy' => 'fgaleri', 'fgaleri' => $myslug ) );
share|improve this answer
Nothing changed, mate... – onur Jul 20 '12 at 14:23
Do NOT post authentication information for your website or server in a public forum. – EAMann Jul 20 '12 at 17:28

I have looked into your code and figured that you have pretty much messed up the code. I have made some changes in your code and now the pagination seems to work fine. I have commented out some action hooks in your functions.php and some lines in archive-fotograf.php. You may uncomment that and look out what was creating the problems

share|improve this answer
Hi. What you did changed? Because I thought my codes doesn't work and I uploaded my theme again. :( Your changes is lost. :( Please, write here what you did. I'm waiting. Thanks in advance. :) – onur Jul 20 '12 at 17:31
I just viewed your website and it seems pagination is working fine, it is showing different posts in each pagination. – rabin shrestha Jul 20 '12 at 17:42
Yes, pagination works in all photos list. but click to Diğer (other) category, and you can see pagination at bottom. And it's still not working. – onur Jul 20 '12 at 17:44
oh yep i didn't see that, let me see if i can fix that – rabin shrestha Jul 20 '12 at 17:46
You know my username and password. Open this link: onurunwebsitesi.com/… It is not working. Thanks for your help! – onur Jul 20 '12 at 17:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.