Support » Fixing WordPress » Using Links Manager to make a directory-how to structure?

  • Resolved Kathy_P


    To understand what I am trying to do, take a look at my current website:
    If you look on the sidebar, you can see I have 3 main categories of links: Cold Climate Gardening (ccg), Cottage Gardening (ctg), and Upstate NY (ny). Each of these is further divided into subcategories of information, gardens, merchants, forums, magazines, and books. If I’m understanding this correctly, it looks like I can assign categories such as ccg-info, ccg-gardens, ctg-info, ctg-gardens, etc., and use the template tag get_linksbyname to show the link name, description or notes (would one be preferable to the other?), and rss feed if available.

    What I’m not clear on is how to structure the Pages. Is it possible to have a ccg template that would generate child Pages for each of the subcategories? If it’s possible, is it desirable, assuming I want to create a menu in the sidebar that shows the subcategories? If each child needs its own Page, does each child also need its own unique template, or can I create a generic template that will serve for all the child Pages? And once I create these Pages, where do I put them? Do they go with the other files in my current theme, or would WordPress look for them somewhere else?

Viewing 6 replies - 1 through 6 (of 6 total)
  • I had some trouble getting my head around this, too. You don’t need to create individual Pages for your categories. All you need is to create category “pages” or templates.

    Follow the instructions on the Codex Article about creating category templates and your problems will be solved. It’s really simple. In a nutshell, you just need to create a new category web page called by the name of the category you want to “feature”. The example uses Category ID 6.

    Following the instructions, make a template file called category-6.php. Using the default template hierarchy when someone clicks on category 6, WordPress first looks for a category-6.php file, then a category.php file, and so on down to the index.php file. If it finds the category-6.php template file, it generates it. No effort from you!

    I’ve done the same thing on my site if you click any of the categories listed at the top or bottom of any page. You will see that the information on each category “page” is different. Drill down through the “important” subcategories and you will see the top content change. On the lessor categories, I allowed it to just go to the category.php template file since the posts are explanation enough.

    Then, on each category template, I used two important tags.

    <?php wp_list_cats('sort_column=name&optioncount=0
    &list=1&use_desc_for_title=1&child_of=4'); ?>

    [make sure this is and the next code are on one line if you use them]

    This says to sort the categories by name in a list, to use the titles and not the descriptions, and to only list the “children” subcategories of category ID # 4, excluding all else. This way, I get a listing of all the subcategories under category 4.

    Then I use the Customized Post Listings by Coffee2Code and use the following tag:

    <ul><?php c2c_get_random_posts(15,
    "<li>%post_URL%</li>", "4"); ?></ul>

    This gets me 15 random posts from category ID 4 to act as “highlights” from that particular category and subcategories.

    I have text at the top of the page that explains the category and all this is followed, as part of the Loop, by excerpts of the posts within that category.

    The only sad part is that for now, if you click “previous entries”, you will get the same text on the next batch of posts in the same category. I haven’t yet figured out how to set this to “know” when this is the first “page” of the category being viewed. Mind reading is the feature WordPress needs to work on next.

    It’s really simple. Within a very short time, maybe an hour or so, I created 20 some unique category pages to explain those categories. You can get into more detail and even set up different style sheets, headers, footers, and sidebars for each category. If you look closely, you will see that I do indeed have a different sidebar for my categories than I do for my front page and posts, showing you the flexibility of this system. It’s pretty slick.

    Good luck with this and let us know how it works for you.

    Lorelle, thank you so much for taking the time to answer me in depth. I’m afraid I didn’t make myself clear. The categories I am talking about are Link categories, not post categories. I did use the word subcategories, but I was referring to how they were organized on my current website. Since Links don’t seem to provide for subcategories, I think (but am not certain) I will have to give them all prefixes of ccg, ctg, and ny to distinguish them.

    I am sure I will not be using The Loop, as I will not be using posts. I know I will be using the Template Tag <?php get_links ?> with several of its parameters. I’m just not sure how to set this tag up in the context of Pages and subPages, using one or more templates.

    I did look at your site, and I might do “something more” with my post categories in the future. But right now I’m interested in getting my current website ported over to WordPress, and a good deal of my website is merely an annotated directory of links.

    Sorry about the confusion. Some people try to create Pages and Posts and have them link through the Link Manager instead of the post categories.

    Good luck and if no one pops in with an answer for your situation, they may assume I’ve answered your question, so reask it, okay. And sorry for the confusion. A lot of people try to put a square peg in the round hole that is WordPress and us volunteers on the forums try to mind read for them to find the answers.

    There isn’t a specific page in the Template Hierarchy related to Links, though I have seen a links.php in some themes. Perhaps I need to use a query-based template? But I feel like I’m getting in over my head when they start talking about plug-in hooks and such. I will go look at a links.php file in one of the other themes to see if it can teach me anything. Maybe with some tweaking I can apply what you did with Categories to Links. And if that doesn’t help, I’ll follow your advice and re-submit the question.

    Thanks for stopping by a second time. A lot of people do “try to put a square peg in the round hole” because they’re trying to understand something they really don’t have a background for. But I have seen other threads on this forum where it really did seem like the poster hadn’t even tried to figure it out for themselves first. On the hand, I have had people quote me “chapter and verse” from the Codex as if I hadn’t read it, when really they didn’t understand my question. See, for example, this thread:

    In case anyone is looking for a similar solution, I solved my problem by using a plugin called Link Library. It is in the plugin repository at

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Using Links Manager to make a directory-how to structure?’ is closed to new replies.