Codeless
  • Support Home
  • Themes
  • Support
  • WordPress Tutorials
    • How to Start a Blog
    • Best Website Builders
    • Best Small Business Hosting
    • Email Marketing Services
    • Cheap WordPress Hosting
  • Video Tutorials

Community Forums

Pagination: Header Link rel="prev" & rel="next"

pagination link tag
    • 7 years, 8 months ago Logismkt
      Participant

      Expired

      Hi,

      We are try to implement the Next and Prev header link tag for pagination but we are experiencing issues.

      First of all, we are using Yoast SEO that theorically do it automatically but the theme use their own pagination system and the plugin can’t read the necessary information to done this.

      However, we have tried to implement in the functions.php the code necessary to do this but without success because of quantity = 0 of the “$wp_query->max_num_pages”.

      There’s is a better way to implement this?

      Thanks.

    • 7 years, 8 months ago Mirela
      Participant

      Hello,

      Theme has build-in the links to next/prev post or portfolio item. This does not included normal pages. Sorry but this is a personal customization that requires coding and it’s not included in support service.
      I suggest you hire a developer to help you with the customizations you need.

      Best regards!

    • 7 years, 7 months ago Logismkt
      Participant

      Expired

      Hi,

      I’ve found the solution. Do you allow me to present this solution in this post to help others?

      Thanks.

    • 7 years, 7 months ago Mirela
      Participant

      Hello,

      Of course! Thank you very much for sharing it with the community!

      Best regards!

    • 7 years, 7 months ago Logismkt
      Participant

      Expired

      Hi,

      The most important reason to implement the pagination atrributes (rel=”next” / “prev”) concerns to the page indexing and avoid content duplication.

      This is the way to give some of context to our content and connection between URLs.

      Read more about this on this Google’s page.

      So… To implement this on the Pagination Function of Tower theme, you need to:

      – Access to the functions-tower.php (wp-content/themes/tower/)

      – At 19’s line start the “Pagination Function”

      – Add variables and code to print this “link tags” (the code added is bold styled)

      /*--------------------- Pagination Function ---------------------------------- */
      
      function codeless_pagination($pages = '', $range = 2){
      
      $showitems = ($range * 2)+1;
      
      global $paged;
      
      if(empty($paged)) $paged = 1;
      
      if($pages == '')
      
      {
      
      global $wp_query;
      
      $pages = $wp_query->max_num_pages;
      
      if(!$pages)
      
      {
      
      $pages = 1;
      
      }
      
      }

      //VARIABLES TO IMPLEMENT THE LINK REL PREV Y NEXT

       $actualPage = $paged;
      
      $previousPage = $actualPage - 1;
      
      $nextPage = $actualPage + 1;
      
      if(1 != $pages)
      
      { 

      // CODE TO PRINT LINK REL PREV Y NEXT BASED ON FIRST PAGE, LAST PAGE AND OTHERS

      if ($paged == $pages) {
      
      echo '';
      
      } else if ($actualPage == 1) {
      
      echo '';
      
      } else {
      
      echo '';
      
      echo ''; }
      
      echo "
      
      Page ".esc_attr($paged)." of ".esc_attr($pages)."";
      
      if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "«"; if($paged > 1 && $showitems < $pages) echo "‹";
      
      for ($i=1; $i <= $pages; $i++) { if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
      
      { $next_link = '';
      
      if($paged + 1 == $i)
      
      $next_link = 'next_link';
      
      echo ($paged == $i)? "".$i."":"".$i."";
      
      }
      
      }
      
      if ($paged < $pages && $showitems < $pages) echo "›";
      
      if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "»";
      
      echo "
      
      \n"; }
      
      }
      
      /*--------------------- End Pagination Function ---------------------------------- */
      

      Hope this results usefull for the community.

      Regards,

      Frederico Metelo.

      • This reply was modified 7 years, 7 months ago by Mirela. Reason: code styling
Viewing 4 reply threads

You must be logged in to reply to this topic.

Login

Log In
Register

Renew Support

  • Renew Specular Support
  • Renew Tower Support
  • Renew Folie Support
  • Renew Handel Support
  • Renew June Support
  • Renew Picante Support
  • Renew Thype Support
  • Renew Regn Support

Search Forums

Forums

  • Bygge – Construction Theme
  • Converta – Software Theme
  • Folie – The WordPress Website Builder
  • Handel – Responsive Multi-Purpose Business Theme
  • June WooCommerce WordPress Theme
  • Livecast – Podcast Theme
  • Picante – Restaurant & Food WordPress Theme
  • Regn | Agency & Business WordPress Theme
  • Remake – Minimal Portfolio & Agency Theme
  • Specular – Multi-Purpose WordPress Theme
  • Suggest us Features
  • Tower – Business-Driven Multipurpose WP Theme
  • Vibrance – Photography Theme

Site Links

  • Support Policy
  • Specular Support Forum
  • Video Tutorials
  • Knowledge Base
  • Guides and Reviews

Useful Articles

  • Build a Website
  • Web Design & Development
  • Hosting
  • WordPress

Login

Log In
Register Lost Password