Is there an easy way to create a links index page?

I think the WordPress bookmarks feature would work grand here. Here’s how I got this to work (generically).

  1. Go to Links->Link Categories and add all the letters of the alphabet as categories
  2. Create a new link, add a description and notes, and assign it to a specific alphabetical category.
  3. Create a page template (as shown below) and place it in your theme folder
  4. Create a new page under Pages->Add New and assign it your page template from step 3.

Here’s what a very elementary, basic, generic template would look like. Save this as tpl-links.php in your theme folder.

<?php
/*
Template Name: Awesome Link Template
*/

$category = $_GET['link_category'];

if($category):
    $args = array(
        'category_name' => esc_sql($category)
    );
    $bookmarks = get_bookmarks($args);
endif;

if($bookmarks):
    foreach($bookmarks as $bookmark):
        echo "link_name - $bookmark->link_name<br>";
        echo "link_url - $bookmark->link_url<br>";
        echo "link_description - $bookmark->link_description<br>";
        echo "link_notes - $bookmark->link_notes<br><br>";
    endforeach;
else:
    //Do Something Here
endif;

You can display certain categories like this: http://yourdomain.com/awesome-link-page/?link_category=a This will display all the links in that alphabetical category. It’s pretty simple.

The cool think about bookmarks is you can really add a lot of information about a link. I added a few of the object elements that you have access to which would be relevant to your application in the page template code. Hope this helps!

Leave a Comment