[wp-hackers] 1 taxonomy on 2 different custom post types

Aero Maxx aero.maxx.d at gmail.com
Tue Aug 21 07:30:57 UTC 2012


On 20/08/2012 11:53, Mike Schinkel wrote:
> On Aug 20, 2012, at 3:55 AM, Aero Maxx wrote:
>> I did a var_dump on $wp->query_vars outside of the if statement in the function you wrote and this is the result.
>>
>> www.domain.com/draw-results/?game=lotto
>> Notice: Undefined offset: 3 in ... /public/wordpress/wp-content/themes/twentyeleven-child/functions.php on line 472 - (This is line 472: 'game' => $matches[3])
>> array(2) { ["post_type"]=> string(12) "draw-results" ["game"]=> NULL }
>>
>> www.domain.com/ball-statistics/?game=lotto
>> array(1) { ["attachment"]=> string(5) "lotto" }
> Oops, I think it should have been:
>
> 'game' => $matches[2],
>
> I tested on a local site but had to change for your site and screwed it up because yours CPTS and my test CPTs are different.  See updated code at:
>
> https://gist.github.com/3390496
>
> Also, why are you testing it with these URLs?
>
>> www.domain.com/draw-results/?game=lotto
>> www.domain.com/ball-statistics/?game=lotto
> I wrote to work with these, which is what you originally asked for:
>
>> http://www.domain.com/draw-results/game/lotto
>> http://www.domain.com/ball-statistics/game/lotto
> -Mike
>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
Oopps sorry I was in a rush to leave for work and I have copy and pasted 
the urls off the wrong post, meant to do the ones that you mentioned.

The problem I had before has gone, but I think there is a problem still 
but not with the code you wrote I believe this would work, I think its 
to do with my register_taxonomy, have pasted it here 
http://pastebin.com/YieR47eQ.

On the draw results page everything works just as it should on the ball 
statistics page it doesn't.

I can only think that its down the rewrite part in the $args for the 
register taxonomy, as I would like the urls to be 
http://www.domain.com/ball-statistics/lotto and 
http://www.domain.com/draw-results/lotto.

Draw Results works perfectly and am sure the Ball Statistics will also 
once have fixed the rewrite part as I think that's the issue.

ball-statistics cpt I get :-
array(1) { ["attachment"]=> string(5) "lotto" }

draw-results cpt I get :-
array(2) { ["post_type"]=> string(12) "draw-results" ["game"]=> 
string(5) "lotto" }

Thanks
Daniel.



More information about the wp-hackers mailing list