vendredi 11 avril 2014

facebook pagination wordpress problem

http://www.shayatik.com/2014/03/facebook-plugin-breaks-wordpress-pagination/#comment-41

best sol is :

When does pagination issue by Facebook WordPress plugin appears?

  • Only on homepage
  • If you are using “Post name” option in Permalink Settings
  • If you are using “Static” homepage option in your Reading Settings which means you are using some custom page template to display your posts in a default loop
The problem with this issue is that WordPress actually generates proper pagination link, (i.e. yourwebsite.com/page/2), but it is somehow always redirected to your home page.

Solution

This handy snippet should do a trick. Make sure it is included somewhere in thefunctions.php file of your theme.
/* Fix pagination issue caused by Facebook plugin */

function meks_fb_plugin_pagination_fix() {

  //Check if plugin is activated and if we are on the homepage
  if(class_exists('Facebook_Loader') && is_front_page()){
    global $wp_query;
    $page = get_query_var('page');
    $paged = get_query_var('paged');

    //Check if we are trying to reach pagination link
    if($page > 1 || $paged > 1){
      unset($wp_query->queried_object);
     }

  }

}

add_action( 'wp', 'meks_fb_plugin_pagination_fix', 99 );

Aucun commentaire:

Enregistrer un commentaire

Nombre total de pages vues