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:
- Link categories are not hierarchical, and;
- 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
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`.
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
- Download and extract this file
- Replace your `/wp-admin/includes/class-wp-links-list-table.php` file with this one
Please leave feedback and improvements, bugs, etc. below in the comments.