[Plugin: Polylang] Homepage pagination bug
-
Hi,
I might have found a bug as the pagination on my homepage does not work.
My home page is actually doing aquery_posts()
on a post custom type and the first page works as expected but when I click on the next/older navigation link then the page url becomes?lang=en&paged=2
and this is trying to render an archive page instead of my static home page.Cheers,
-
I do not reproduce this last bug (I retested). Did you try to refresh your permalink structure (Just go to settings->permalinks and click on save changes) ? Does the bug occur with both 0.8.7 and the dev version ?
This bug is happening on both version (0.8.7 and 0.8.7.5) for the following URL:
/?tag=css&paged=2
. I do have 13 posts (actually custom types & posts as I’ve modify $wp_query to include to include the custom types as well) and I display 6 of them per page, that’s why the navigation link is generating the previous page link.
I don’t think it’s linked to my code though as it is showing the 404 page and not my archive.phpIf I understood well:
You use a static homepage.
You use default permalinks.
What are your Polylang settings ?Did you try with a default theme (twenty ten for example) and with all other plugins deactivated (to see if it could come from a conflict) ?
Yes I have a static homepage with a custom query to display onli a specific custom type (“project”), but everything’s fine on the homepage, even the pagination.
Actually I use the/%postname%/
but in order to be sure it wasn’t an error on the permalinks, I temporarily switched it to the default/?p=X
.I tried to deactivate all the other plugins with no success. Here’s the SQL query for the first (working) page of the tag CSS: [“request”]=> string(546) “SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_term_relationships AS tt1 ON (wp_posts.ID = tt1.object_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (60) AND tt1.term_taxonomy_id IN (32) ) AND wp_posts.post_type IN (‘project’, ‘post’) AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_author = 1 AND wp_posts.post_status = ‘private’) GROUP BY wp_posts.ID ORDER BY wp_posts.menu_order, wp_posts.post_date DESC LIMIT 0, 6”
When I activate the twenty eleven theme, I’ve got nothing for this particular CSS tag page, because there’s no posts linked to it. I only have custom types posts (project) in this tag so far.I think the issue is that it thinks there’s no posts to display so redirect to the 404 template whereas there are actually custom types to display. I think the isuue comes from the fact that I’m using tags in my custom type. Hopefully this will help you solve the issue.
One last thing I noticed is that on the
/?tag=css
page, thesingle_tag_title()
function does not returnCSS
as expected but the current language (English in this case).Two terms (32 and 60) are queried. Which one corresponds to your tag css. What is the other one ?
Very true!
The CSS tag is the ID 32, and the ID 60 is actually the English (slug = ‘en’) from what I can read in the wp_terms table.
That explains whysingle_tag_title()
is displaying ‘English’.It’s strange because Polylang should never query the language on terms and post pages (there is no need). Moreover, I do not know from where this ‘tt1’ is coming from. However your are the second user who reports such thing. I have to find out what happens.
Which are your Polylang settings in the language settings page ?
Very strange indeed as I do not even query the language parameter on this page.
I set up 3 languages: English (default), Espa?ol and Fran?ais. Each of them has a specific menu and on the menu page I checked only “displays flag” and “hides current language”. I just change the values of search in frnch and spanish in the strings translation tab.
Finally, in the settings page, English is defined as default, detecte browser language is ticked, the remove /language/ checkbox is choosen, and redirect the language page is ticked as well.Cheers
Well, it probably does not come from the settings. As you, I now believe that it is the combination of tags and custom post types in the same query which is badly handled by Polylang.
Could you explain how you force your custom post types in the tag page so that I try to reproduce the bug on my test site?
That’s the query I’m using on the archive page:
global $wp_query; $args = array_merge( $wp_query->query, array( 'post_type' => array('project', 'post') ) ); query_posts( $args );
One of the reasons why I choose to display my custom type with the actual posts is because some of the tags I’m using for custom types are the same as some for my actual posts, and therefore it’s counting the total of posts AND custom types. For instance I have this CSS tag: there are 13 ‘project’s at the moment and no posts, but there will be some.
I don’t mind not having them displayed on the archive.php page, but in this case how could they not add them to the total of their tags?Anyway, tell me if you need any more information as I’m a developer by day and if you want me to edit/add any line of code instead of re-uploading your dev version all the time, I will be happy to help you as although your plugins have some bugs at the moment, it looks the cleanest, easiest and most efficient one for multi language purposes on wordpress.
I found some possible conflicts between taxonomies, language taxonomy and custom post types. You can either download the new dev version I just uploaded (0.8.7.7) or modify the file core.php and add these lines
// to avoid conflict with beetwen taxonomies foreach ($query->tax_query->queries as $tax) if (in_array($tax['taxonomy'], $this->taxonomies)) unset ($qvars['lang']);
at line 372, just above the line:
if (PLL_DISPLAY_ALL) {
It should solve at least partly the issue (maybe not the 404 error on /?tag=css&paged=2 as I did not reproduce this). However I made some tests before reading your answer with only the custom post type. I did not merge it with standard posts. I will try this too.
I am sorry but I will be out for several days, so if the issue is not completley solved, I will not be able to go on working on it before some time.
Indeed adding those lines did not solve the issue.
That’s fine, don’t worry I still have some time before using this website. When do you think you’ll be able to work on it again?
Thanks for all the efforts you put into this ??
Bad copy paste. the code above does nothing and the 0.8.7.7 broke some things. Here is the corrected modification:
// to avoid conflict beetwen taxonomies if (isset($query->tax_query->queries)) foreach ($query->tax_query->queries as $tax) if (in_array($tax['taxonomy'], $this->taxonomies)) unset ($query->query_vars['lang']);
Yes indeed, it did fix the
single_tag_title()
issue, and as you already said I’ve still got the pagination error.
- The topic ‘[Plugin: Polylang] Homepage pagination bug’ is closed to new replies.