Problème de pagination WordPress / page / 2 404 - que faire?
-
-
Exécutez-vous votrepropre requête dans lemodèle?Cela seproduitgénéralement lorsque vous écrasezincorrectement la requête dans lemodèlepour changer `posts_per_page` ou un autreparamètre de requête.Are you running your own query in the template? This typically happens when you incorrectly overwrite the query in the template to change `posts_per_page` or some other query parameter.
- 0
- 2015-11-24
- Milo
-
Jene me souvienspas avoirtouché une seule ligne de code.Commentpourrais-je vérifier cela?I don't remember touching a single line of code. How could I check this?
- 0
- 2015-11-24
- Giovanna Cóppola
-
Si vousn'avezpasmodifié lethèmeet que leproblèmepersiste avectous lesplugins désactivés,vous devez demander à lapersonne qui a créé lethème.If you haven't modified the theme and the problem persists with all plugins disabled, then you should ask the person who created the theme.
- 0
- 2015-11-24
- Milo
-
Mercipour votretemps,Milo.J'ai simplementinstallé unplugin qui a résolu leproblème.Je vais répondre à cette questionet fournir le lien.Thanks for your time, Milo. I simply installed a plugin that solved the problem. I will answer this question and provide the link.
- 0
- 2015-11-27
- Giovanna Cóppola
-
Changer simplement leparamètre depagination de "paginé" à "page" a résolu leproblème dansmon cas.Simply changing the pagination parameter from "paged" to "page" fixed the issue in my case.
- 0
- 2020-03-17
- user54002
-
11 réponses
- votes
-
- 2015-11-27
J'aitrouvé la solution!
L'installation de ceplugin a résolu leproblème: https://wordpress.org/plugins/category-pagination-fix/
J'ai également dû apporter desmodifications dans Paramètres> Lecturepour affichermoins de 10 articlesparpage (j'affiche 6 articlesparpagemaintenant,maistout ce quiestinférieur à 10 devraitfonctionner).
J'espère que celafonctionnepour voustous.:)
Found the solution!
Installing this plugin solved the problem: https://wordpress.org/plugins/category-pagination-fix/
I also had to make changes in Settings > Reading to show less than 10 posts per page (I'm showing 6 posts per page now, but anything below 10 should work).
Hope it works for you all. :)
-
unplugin obsolète corrigeant unproblème spécifique avec wordpress qui a été corrigé dans lenoyauil y a 6 ans?peuprobable que ce soit unebonne réponsean outdated plugin fixing a specific problem with wordpress which was fixed in core 6 years ago? unlikely this is a good answer
- 1
- 2017-08-20
- Mark Kaplun
-
Leplugin étaitpar défautinterditpourmoi,mais vousm'avezindiqué labonne direction avec le changement deparamètres!Merci!The plugin was by default a no-go for me, but you pointed me to the right direction with the Settings change! Thanks!
- 2
- 2018-03-21
- daneczech
-
- 2018-03-10
J'aieu lemêmeproblèmeet j'ai remarqué que dans les
'posts_per_page = 6'
et'Settings/Reading
sur l'argument WordPress' options-reading ',j'étais définià 10. Quandj'aimistout à lamême valeur (6 dansmon cas),tout a recommencé àfonctionner.I had the same problem and I noticed that in the
'posts_per_page = 6'
and'Settings/Reading
on 'options-reading' WordPress argument, I was set to 10. When I put everything to the same value (6 in my case) everything started working again.-
Life Saver @jeferson,merciLife saver @jeferson, thank you
- 0
- 2020-04-28
- Anahit DEV
-
- 2018-07-17
J'aiessayéplusieurs heures,jusqu'à ce queje trouve une solutionfonctionnelle dans cet article .
Dans votrefichier
functions.php
,ajoutez/** * Fix pagination on archive pages * After adding a rewrite rule, go to Settings > Permalinks and click Save to flush the rules cache */ function my_pagination_rewrite() { add_rewrite_rule('blog/page/?([0-9]{1,})/?$', 'index.php?category_name=blog&paged=$matches[1]', 'top'); } add_action('init', 'my_pagination_rewrite');
Remplacez
blog
par lenom de votre catégorie dans le code ci-dessus.Après avoir ajouté ce code,assurez-vous d'aller dans
Settings > Permalinks
et cliquez surSave
pour vider le cache des règles,sinon la règlene serapas appliquée.J'espère que cela vous aidera!
Tried several hours, until I found a working solution in this article.
In your
functions.php
file, add/** * Fix pagination on archive pages * After adding a rewrite rule, go to Settings > Permalinks and click Save to flush the rules cache */ function my_pagination_rewrite() { add_rewrite_rule('blog/page/?([0-9]{1,})/?$', 'index.php?category_name=blog&paged=$matches[1]', 'top'); } add_action('init', 'my_pagination_rewrite');
Replace
blog
with your category name in the code above.After adding this code, make sure you go to
Settings > Permalinks
and clickSave
to flush the rules cache, or else the rule will not be applied.Hope this helps!
-
Cela l'afaitpourmoi.J'adoreraistoujours savoir le «pourquoi» de ce comportement surgissant denullepart.Maismercipour le correctif.This did it for me. Would still love to know the 'why' of this behavior popping up out of nowhere. But thx for the fix.
- 0
- 2019-04-26
- dashard
-
- 2017-08-16
J'aitrouvé que changer la structure dupermalienfonctionnaitpourmoi,regardez:
Lepermalien était comme ceci dans la structurepersonnalisée:
/index.php/%year%/%monthnum%/%day%/%postname%/
Ensuite,je l'ai changéen: Jouret nom (sélectionnez simplement lebouton radio)et cela ressemblera à ceci:
/%year%/%monthnum%/%day%/%postname%/
J'aiessayéet çamarche!
I found changing the permalink structure work for me, look:
The permalink was like this in custom structure:
/index.php/%year%/%monthnum%/%day%/%postname%/
Then I changed it to: Day and name (just select the radio button) and it will look like this:
/%year%/%monthnum%/%day%/%postname%/
I tried this and it works!
-
J'ai constaté que le simple chargement de lapage de lienpermanent résolvait leproblèmeI found that simply loading the permalink page cleared the issue
- 0
- 2019-05-10
- jerrygarciuh
-
- 2018-12-06
Dansmon cas avec des lienspersonnalisés:/% category%/%postname%/ J'aieu unproblème avec:/news/page/2/
Etenfin celafonctionnepourmoi (ajouter àfunctions.php):
function remove_page_from_query_string($query_string) { if ($query_string['name'] == 'page' && isset($query_string['page'])) { unset($query_string['name']); $query_string['paged'] = $query_string['page']; } return $query_string; } add_filter('request', 'remove_page_from_query_string');
In my case with custom links: /%category%/%postname%/ I had a problem with: /news/page/2/
And finally this works for me (add to functions.php):
function remove_page_from_query_string($query_string) { if ($query_string['name'] == 'page' && isset($query_string['page'])) { unset($query_string['name']); $query_string['paged'] = $query_string['page']; } return $query_string; } add_filter('request', 'remove_page_from_query_string');
-
- 2019-01-19
ma solutionesten 3 étapes:
1- lepremier: Installation de ceplugin: https://wordpress.org/plugins/category-pagination-fix/
2-alors:machinez votremorue avec cette structure
<?php $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; ?> <?php $q=new wp_Query( array( "posts_per_page"=>10, "post_type"=>"", "meta_key"=>"", "orderby"=>"meta_value_num", "order"=>"asc", "paged" => $paged, ) ); while($q->have_posts()) { $q->the_post(); ?> <li></li> <?php } wp_reset_postdata(); ?> <div class="pagination"> <?php global $q; $big = 999999999; // need an unlikely integer echo paginate_links( array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', 'current' => max( 1, get_query_var('paged') ), 'total' => $q->max_num_pages ) ); ?> </div>
3-go dans lesparamètres wordpress> lecture> leplusgrandnombre demessagesparpage deblog puis saisissez lenuméro 1
my solution is in 3 step:
1- the first one : Installing this plugin : https://wordpress.org/plugins/category-pagination-fix/
2-then : mach your cod with this structure
<?php $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; ?> <?php $q=new wp_Query( array( "posts_per_page"=>10, "post_type"=>"", "meta_key"=>"", "orderby"=>"meta_value_num", "order"=>"asc", "paged" => $paged, ) ); while($q->have_posts()) { $q->the_post(); ?> <li></li> <?php } wp_reset_postdata(); ?> <div class="pagination"> <?php global $q; $big = 999999999; // need an unlikely integer echo paginate_links( array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', 'current' => max( 1, get_query_var('paged') ), 'total' => $q->max_num_pages ) ); ?> </div>
3-go in wordpress setting > reading > most number of posts per page of blog then input number 1
-
- 2019-01-31
Comme d'autres l'ontmentionné.Assurez-vous que votre 'posts_per_page=6'est égal ouinférieur auparamètre Paramètres Wordpress> Lecture> Lespages deblog s'affichent aumaximum.
J'ai récemment rencontré ceproblèmeet leproblèmeest queje contrôle complètement lespublicationsparpage àpartir dufichiermodèle.S'iln'y apas assez demessagespour la dernièrepage,ce sera 404.
parexemple.J'aimespublicationsparpage sur 9,maisj'aieu 25publications.lespages unet 2fonctionneraientmais lapage 3fonctionnerait 404. J'ai défini leparamètre WordPress sur 1et laissémonfichier demodèle sur 9et ilfonctionnemaintenant commeprévu.
As others had mentioned. Make sure your 'posts_per_page = 6' is equal or less than the Wordpress Settings > Reading > Blog pages show at most setting.
I ran into this issue recently and the issue was that I control the posts per page completely from the template file. If There are not enough posts for the final page it will 404.
for example. I have my posts per page set to 9, but I had 25 posts. page one and 2 would work but page 3 would 404. I set the WordPress setting to 1 and left my template file at 9 and it is now functioning as expected.
-
- 2019-07-20
Dansmon cas,en utilisant Diviet leplugin PageNavi,la raisonpour laquellej'obtenais le 404 était que lemodèle depage (archive dansmon cas) obtenait leparamètre de requête
paged
en utilisantget_query_var( 'paged' )
,à laplace,tout ce quej'avais àfaire était d'utiliser la variableglobale comme ci-dessous:<?php /* Template Name: Archives */ get_header(); ?> <?php // $paged is a global variable provider by the theme? global $paged; $args = array( 'posts_per_page' => 4, 'post_type' => 'axis', 'paged' => $paged, ); $myposts = new WP_Query($args); ?> <div div style="width: 50%; margin: 0 auto;"> <?php while ( $myposts->have_posts() ) : $myposts->the_post(); ?> <div class="media-body"> <?php the_content(); ?> </div> <?php endwhile; wp_reset_postdata(); ?> <?php wp_pagenavi( array( 'query' => $myposts ) ); ?> </div> <?php get_sidebar(); ?> <?php get_footer(); ?>
Ce code a corrigéet résolu lesmessages duformateur
post-name/page/N
. Leparamètre depermalienest défini sur "Nom dumessage",c'est-à-direhttp://localhost/sample-post/
In my case, using Divi and the PageNavi plugin, the reason I was getting the 404 was that the page template (archive in my case) was getting the
paged
query parameter usingget_query_var( 'paged' )
, instead all I had to do was use the global variable like below:<?php /* Template Name: Archives */ get_header(); ?> <?php // $paged is a global variable provider by the theme? global $paged; $args = array( 'posts_per_page' => 4, 'post_type' => 'axis', 'paged' => $paged, ); $myposts = new WP_Query($args); ?> <div div style="width: 50%; margin: 0 auto;"> <?php while ( $myposts->have_posts() ) : $myposts->the_post(); ?> <div class="media-body"> <?php the_content(); ?> </div> <?php endwhile; wp_reset_postdata(); ?> <?php wp_pagenavi( array( 'query' => $myposts ) ); ?> </div> <?php get_sidebar(); ?> <?php get_footer(); ?>
This code corrected linked and resolved
post-name/page/N
formatter posts. The permalink setting is set to "Post Name" i.e.http://localhost/sample-post/
-
- 2020-03-17
Dansmon cas,j'avais cecien boucle:
if (is_category()) $args['posts_per_page'] = 8;
Et dans Paramètres-> Lecture,j'avais 10 articlesparpagepour lebloget la syndication
J'ai changé à 8 articlesparpage dans Paramètres-> Lectureet maintenant le 404 a disparuet tout semblefonctionner.
Jene saispaspourquoimais celapourraitprobablement aider quelqu'un à l'avenir
In my case I had this in a loop:
if (is_category()) $args['posts_per_page'] = 8;
And in Settings->Reading I had 10 posts per page for blog and syndication
I changed to 8 posts per page in Settings->Reading and now the 404 disappeared and everything seems to work.
I have no idea why but probably this could help someone in the future
-
- 2020-08-22
Voici unegénéralisation de la réponse de kregus qui corrigetoutes les catégories à lafois:
/** * Fix pagination on archive pages */ function my_pagination_rewrite() { $categories = '(' . implode('|', array_map(function($category){return $category->slug;}, get_categories())) . ')'; add_rewrite_rule($categories . '/page/?([0-9]{1,})/?$', 'index.php?category_name=$matches[1]&paged=$matches[2]', 'top'); } add_action('init', 'my_pagination_rewrite');
Here's a generalization of kregus's answer that fixes all categories at once:
/** * Fix pagination on archive pages */ function my_pagination_rewrite() { $categories = '(' . implode('|', array_map(function($category){return $category->slug;}, get_categories())) . ')'; add_rewrite_rule($categories . '/page/?([0-9]{1,})/?$', 'index.php?category_name=$matches[1]&paged=$matches[2]', 'top'); } add_action('init', 'my_pagination_rewrite');
-
- 2017-01-19
J'obtiens l'erreur 404 lorsqueje retourne à l'url avec
/page/2/...
.Je vais donc surmapage WordPress 404et ajoute cejavascripten haut de lapage d'erreur:<script src="https://code.jquery.com/jquery-1.10.2.js"></script> <script> var getreurl = window.location.href; if(getreurl != ""){ var res = getreurl.split("/?"); if(res[1] != ""){ var resd = "http://www.yourwebsite.com/list/?"+res[1]; window.location = resd; } } </script>
Quandje retourne à lapage 404 oùelle contient l'URL,j'analyse l'URLet j'obtiens la chaîne d'URL dontj'aibesoinet je reconstruis unnouveau lienpuisje redirige sur lenouveau lien reconstruit.
I'm getting the error 404 when I head back to the url with
/page/2/...
. So I go to my WordPress 404 page and add this javascript on the top of the error page:<script src="https://code.jquery.com/jquery-1.10.2.js"></script> <script> var getreurl = window.location.href; if(getreurl != ""){ var res = getreurl.split("/?"); if(res[1] != ""){ var resd = "http://www.yourwebsite.com/list/?"+res[1]; window.location = resd; } } </script>
When I head back to the 404 page it carries the URL, I parse the URL and get URL string that I need and rebuild a new link then redirect on the new rebuilt link.
-
La solutionbasée sur JS donneratoujours 404 àgoogle/facebooketc. Iln'y a aucune raison dene pasexécuter cetype de code du côtéphpJS based solution will still give 404 to google/facebook etc. There is no reason not to run this kind of code on the php side
- 1
- 2017-01-19
- Mark Kaplun
Je suistombé sur leproblème depagination
/page/2
404et j'aiessayé detrouver une solution.J'ai lu quelques suggestions,mais celan'apasencore aidé.Fonctionnement: http://pandasnacozinha.com.br/bolos-doces-e-sobremesas/
Nefonctionnepas: http://pandasnacozinha.com.br/bolos-doces-e-sobremesas/page/2/
J'essaie de comprendre cela depuis des heures.Je comprends que WordPress suppose que "page"est un article de la catégorie "bolos,docese sobremesas" carma structure de lienpermanentest
/%category%/%postname%/
maisje ne saispas comment corrigerça.