-
-
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.
-
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!
-
Hi,
I’ve found the solution. Do you allow me to present this solution in this post to help others?
Thanks.
-
Hello,
Of course! Thank you very much for sharing it with the community!
Best regards!
-
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 ago by Mirela. Reason: code styling
-
You must be logged in to reply to this topic.