Categories
Code WordPress

Paginate Links in WordPress Link Manager

Links are not first-class citizens in WordPress

In developing the a website for professional genealogists, I was tasked with creating link directory functionality in WordPress. I didn’t want to install some big plugins; I wanted to use the Links Manager that’s built in to every WP install out of the box. There were two problems, however:

  1. Link categories are not hierarchical, and;
  2. There is no pagination in the Links Manager: all links are displayed on one page by default.

My client’s website will have over 20,000 links; having them all on one page was simply not an option.

I didn’t want to create a new Post Type or Taxonomy; Links are already the right tool for the job. I moved forward creating the custom solution, and am sharing the results of that development here. The result of the project was a successful deployment of a crazy amount of links (see an example on their Iowa genealogy resources page).

Hierarchical link categories

Hierarchical Link Categories
Hierarchical Link Categories

To solve the hierarchical link category issue, I created a plugin that defined the link taxonomy before WordPress, allowing link categories to be hierarchical. A few changes to the backend, and it worked properly.

Paginated link pages

For some reason, WordPress has treated links as an illegitimate child for years. They impose limits on the functionality (such as non-hierarchical categories) for no reason. A perfect example is that every other taxonomy (posts, pages, media, users, plugins, and even themes) has pagination functionality out of the box.

WordPress 3.1 completely revamped the link manager and most of the taxonomy functionality. This made implementing paginated links as simple as modifying one file. I hoped that I would be able to code this as a plugin, but achieving link manager pagination functionality without modifying core files was impossible. I went to work hacking the file responsible for the backend links manager display: `/wp-admin/includes/class-wp-links-list-table.php`.

WordPress Link Pagination
292 pages of links, with 800 more to come!

I ended up with a solution that works, but lacks some of the basic functionality that other taxonomies have: there is no box in the Screen Options tab that allows you to change how many links per page are displayed. There is, however, a filter (`edit_links_per_page`) that allows you to modify this number yourself.

It’s a huge improvement and makes managing large numbers of links possible. Before, the database load itself was ridiculous, let alone the MB’s of HTML that had to load. Now, managing large numbers of links is as painless as it should have been from the start.

Download the modified file

To install:

  1. Download and extract this file
  2. Replace your `/wp-admin/includes/class-wp-links-list-table.php` file with this one

[download id=”10″]

Please leave feedback and improvements, bugs, etc. below in the comments.

By Zack Katz

Zack Katz is the founder of GravityKit and TrustedLogin. He lives in Leverett, Massachusetts with his wife Juniper.

15 replies on “Paginate Links in WordPress Link Manager”

Hi,

I’m trying to paginate blogroll also. I’ve tried to download your class, but the zip file is not valid.

I’m trying to get the links from a specific category but i can’t figure out how the “link_id” from “wp_links” relates to  “wp_terms_relationship”… :/ any help would be great! cheers

Hi, I’m trying to download the modified file but every time I try to unzip it, it says that the file is corrupt. Can you check it?

Once I replace the links-list-table, how I paginate a single category? just use it as a template for a new page? Where can I find more information?

thanks very much

Web Development India

Web development by India’s professional  web development India company offering affordable web

development, unique website development, custom web development creative website

design, logo design, flash design around the world.Further detail you can visit

http://www.webplanet.co.in/web-development.php

Hey did you submit this to the core team to look at?  Maybe you can get this added to core and get some support in the core to make it even better!

Hi,

I’m very interested in your plugin, but when I’ve installed it from the plugin manager, the links sub-categories were not displayed on the blog… (but in the manager, it’s OK, I see my sub-categories).

I also can’t extract your php file : the file is corrupted 🙁
Could you verify it and tell me where can I download it ?

Thank you very much 🙂

20,000 links and hierarchical link category doesn’t seem amusing to me. I would have time to browse all the links after all. This is a good plugin, thanks for sharing it.

eCommerce Hosting for everyone by Nexcess.

The download link for this article does not currently work. We just see a shortcode for it. Can you upload the file back?

I figured it was likely specific to that version, but I still wanted to get an idea of your approach to see if there might be any way to generalize it.

Your ‘class-wp-links-list-table.php’ is not compatible with the WordPress 3.8,3.9.
Please compatible with the latest version of WordPress.

ASC LIMIT does not work.
$args[‘order’] = “ASC LIMIT {$start},{$per_page}”;

thanks.

Comments are closed.