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

404 error on multiple author page WordPress

  • SOLVED

Hi,

I'm using an author template to show the posts of that author. It's working great for the first page, but when I go to another page, it gives me an 404 error page.

http://celebrites.mesopinions.ca/author/frankthetank = WORKS
http://celebrites.mesopinions.ca/author/frankthetank/page/2 = 404

I did recreate a test on my local machine with the same settings and it works ! I also recreated the .htaccess file to be sure and still the 404. I'm using something similar on my other site and I do not get an 404 error ( http://mesopinions.ca/author/frankthetank/page/2 ). I also tried with the twenty ten theme but I get the same error (it give's me the same url).

I already went to the permalink page in admin to regenerate everything, still the 404.
The only thing I see that may cause this problem, is that I created custom post types and moves normal posts to the new custom post types.

Any idea what is causing this ?
Thanks a lot

Answers (3)

2010-07-22

wjm answers:

Hi Francois,
I am more than sure this has to do with rewrite rules.
you may be missing the rule for AUTHORNAME/pages...
maybe the cannonical feature is interfearing.


Add this to your functions.php file to help me diagnose what you have.


add_action( 'wp_footer', 'childtheme_print_matched_rewrite_rule', 100 );
function childtheme_print_matched_rewrite_rule() {
global $wp, $wp_rewrite;
echo "<!--\n";
echo 'matched_rule: '.$wp->matched_rule."\n";
echo 'matched_query: '.$wp_rewrite->rules[$wp->matched_rule]."\n";
echo 'matched_query (evaluated): '.$wp->matched_query."\n";
print_r($wp_rewrite);
echo "-->\n";
}


and post the results (which will be at the end of your 404 page) to wordpress.pastebin.com



Frank TheTank comments:

Hi,

Here is the post. Seems like it did find the good match :
matched_rule: author/([^/]+)/page/?([0-9]{1,})/?$

http://wordpress.pastebin.com/tvnkVH73


wjm comments:

sounds everything is fine,
wonder why

add this at the bottom of your functions.php

add_action( 'template_redirect', 'childtheme_disable_canonical', 9);
function childtheme_disable_canonical() {
remove_action('template_redirect', 'redirect_canonical');
}
global $wp_query;
print_r($wp_query);



and paste to pastebin the results


Frank TheTank comments:

Here is the pastebin

http://wordpress.pastebin.com/nG4eXFuQ


wjm comments:

how can it be different than what you pasted replying to oleg?


Frank TheTank comments:

Not quite sure why it's different... I will give $ to both, since you both helped me out.


wjm comments:

Frank,
you can hire Oleg, i am pretty sure he will be able to solve this issue.
Just give him access to the server, and i am pretty sure he will be able to solve it.


wjm comments:

mmm...
try replacing

'author_name'=>$curauth->nickname,

with

'author_name'=>$curauth->user_login,

but i dont know if that will help

2010-07-22

Oleg Butuzov answers:

insert

echo '<pre>';
var_dump($wp_query);
exit;

to debug information whitch resives wp to get data.


Frank TheTank comments:

Here is the debug generated :

http://wordpress.pastebin.com/6LtVx2v4


Oleg Butuzov comments:

$wp_query is correct.
everything works.

you can see that this sql query (a result of the wp_query)

SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND (wp_posts.post_author = 2) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') ORDER BY wp_posts.post_date DESC LIMIT 9, 9

is returning a zero rows. that means than to posts found that fits the needs.

check perhaps some of the posts made by author is a draft or scheduled (future) - thats why its not visible for the sql query


Oleg Butuzov comments:

easy way to check.. make (in Options-> reading ) a numer of posts per page for 3 and check that evrything working.


Frank TheTank comments:

The error seems to be with the post_type = 'post'.

In my author template, my args are :

$args=array(
'author_name'=>$curauth->nickname,
'post_type'=> array('photos','videos','nouvelles'),
'paged'=>get_query_var('paged')
);


Oleg Butuzov comments:

btw its also can be a problem related for page navi plugin. i think better to give acces to one of the experts that tring help you here. i can recomment wjm or me. but i think 4 $ is a bit law for solving such issue only in chatting mode.


Oleg Butuzov comments:

2<strong>wjm</strong>
becaus other query_posts running i think.

guys please end by wp_reset_query() your custom query_posts. overload it!


Oleg Butuzov comments:

solution can be easy...

add_filter('parse_query', 'parse_query_handler');

function parse_query_handler($q){
if (isset($q->query_vars['author'])){
add_filter('query', 'custom_query_parse');

}
return $q;
}


function custom_query_parse($sql){
return str_replace("wp_posts.post_type = 'post'", wp_posts.post_type IN ('photos','videos','nouvelles'), $sql);
}


Oleg Butuzov comments:

OOPS!

function custom_query_parse($sql){

return str_replace("wp_posts.post_type = 'post'", "wp_posts.post_type IN ('photos','videos','nouvelles')", $sql);

}


Oleg Butuzov comments:

wjm frank...

Query is OK!

no really...

let me describe how it works..


wp found that you look for a author... and its paged...
inner query posts running!

if (posts found){
show a template

in you template is custom query posts .. there is three different posts types...

page navi genenrating paging based on last custom query posts...

//but whan it looking for the page 20... the no posts on 20 page... and wp dosn't load the template. and we got 404. i didi describe how to cheat wp to get not posts - to get all required post types...
understand?
} else {

404

}



// THANKS GOD I AM TELEPATHIC!


Oleg Butuzov comments:

wp has a primitive MVC structure...

in our case

rewrite.php and query.php and hooks is a controller...
query.php and hooks is model...

template is a view...

in short words you tring to get data (witch should be done in model) in a view...

Frank thanks for a nice question. i like it.


Frank TheTank comments:

No problem, good thing you like it.
I tried to add the function to replace the part of the sql that is not working, but still go to the 404 and with the post_type='post'.

I will give the 4$ to wjm and more to you via paypal if you like (I can create another question for the follow up).

I understand what you're saying but not quite sure how I can fix it...


Oleg Butuzov comments:

My hour rate is 25$. i can check your templates. i cannot accept paypal . sorry. ukraine is banned for such operations on paypal. but you can increase the prise...


Frank TheTank comments:

No problem.
Is it easier to just make another question, 25$ for the hour ?
And what is the best thing to do for you to be able to access the files ? Create an administrator account ?


Oleg Butuzov comments:

will be fair if you can check this question - what for to create one more?
yeap one hour. but i belive i can help to make it much faster.

i will need only ftp. (hurry 3:21 am in Ukraine, want to sleep =))


Frank TheTank comments:

Well, this question is only worth 4$. Can't seem to add 25$ to it. I want to make another question so I can pay you.
Website seems down for a strange reason, you can go sleep, I will prepare the ftp access so you can check tomorrow.
Can you leave me your email so I can send you the information ?


Frank TheTank comments:

Website is back. Nevermind.


Oleg Butuzov comments:

my mail in my profile...

hm. we need to tell Lawrence to make a tutorials for this website. i defiantly saw few times how people increase the award


Frank TheTank comments:

Found it. Increased.
Sending ftp informations.


Frank TheTank comments:

Took you 15 mins to fix it ! Good job hehe.


Oleg Butuzov comments:

it took 3 minutes to remove error that i bring.
it took less 1 minute to write a custom functions that change wp_query and comment your query posts call.
it took about 2 hours of our nice chatting and brain storming.
it took 3 years to learn hot to make it in few seconds.


Frank TheTank comments:

Haha thanks a lot ! I appreciate. I'll come back if I get anymore error ! Now go to sleep.

2010-07-22

Rashad Aliyev answers:

Please check your plugins.


Frank TheTank comments:

Did try to desactivate all plugins, still not working.