Support » Themes and Templates » Linking to wp list categories

  • Hi,

    I have added the following code to my home.php file

      <?php wp_list_categories(‘orderby=id&show_count=1&use_asc_for_title=0’); ?>

    It does what I want it to great stuff. However what I would like is for the same category list to be displayed on its own without the archive.

    I figure I add the code to a category page, but what I can’t figure out is how to make a link to call that category.php page.

    All I am wanting to do is display a liste of categories and child categories that I get to by clicking a link?

    Anyway understand what I mean and can help please

Viewing 13 replies - 1 through 13 (of 13 total)
  • Do you mean that it is showing the post counts? If so, change “&show_count=1” to “&show_count=0” (or get rid of it completely.)

    Thread Starter drweb3110

    (@drweb3110)

    Hi I didnt think I made myself too clear – sorry. I want to put a html link in a menu bar or a page that points to a list of categories and there child categories. All I need to understand is what the link would be.

    In other words I can create the query but dont know how to call address it in a link.

    Thank you for your help though

    You want a single link that points to a page with a list of categories, is that it?

    It sounds like you are looking to create a page template that has its content display your category list.

    Have a read of this: http://codex.wordpress.org/Pages
    Especially this section: http://codex.wordpress.org/Pages#Page_Templates

    Thread Starter drweb3110

    (@drweb3110)

    Yeh I have a page template with the code in and it does what I want it too. What I thought is I could save it as a category template and call it from a link but perhaps not?

    Thank you for your help I’ll take a look at the articles you have posted

    You can create a category archive template in a similar fashion … have a look at this page: http://codex.wordpress.org/Category_Templates

    It does seem more appropriate and is perhaps even easier to implement.

    Thread Starter drweb3110

    (@drweb3110)

    Thank you once again – I have created that category template. All I want to do is place a link on a page that goes to the category template – I cant work out what the link is.

    Category templates work by default when you choose the specific category.

    If you have a category called “featured” and you want those posts to be shown differently than when you look at other category posts via the archive template then you would create the category-featured.php template and let it do its thing.

    To accomplish the same thing on a “page” would typically require writing the code as a page-template.

    Try this (un-tested) as the basis for your page template:

    get_header();
    get_template_part( 'category', 'featured' );
    set_sidebar();
    get_footer();

    Thread Starter drweb3110

    (@drweb3110)

    Thank you so much again …. what link code do I use to call the category template and display the results? http://mysite.com/?????.php

    Once you’ve created and uploaded the page template with your code, you’ll have to go into your WordPress admin, add a new page, and select that template. Once you publish the page, it will automatically be in your pages menu.

    Noo… category templates are not applied like Page templates.

    Thread Starter drweb3110

    (@drweb3110)

    I know category templates aren’t applied like pages. And thank you everyone for helping with this.

    OK I have created a category template fine.
    I now want to put a link using a text widget in to my side bar so when viewers click on it they will see the content generated by the category template.

    Hope this now makes sense.

    Sorry, my bad. I thout the idea was to create a page with a list of categories.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Linking to wp list categories’ is closed to new replies.