WordPress.org

Ready to get started?Download WordPress

Forums

How do I pasa a url parameter to wp_list_categories (1 post)

  1. greenapplewebs
    Member
    Posted 3 years ago #

    I want to pass a URL parameter to wp_list_categories so when my sub-cagtegories are displayed and then clicked by a user, they are taken to a page where the posts are sorted by the highest rated post first.

    I need to append this to each subcategory link:
    ?r_sortby=highest_rated&r_orderby=desc

    my code looks like this:

    <?php if (is_category('illinois-bars')) { ?>

    <?php if (is_category()) {
    $this_category = get_category($cat);
    if (get_category_children($this_category->cat_ID) != "") {
    echo "<h1>Subcategories</h1>";
    echo "

      ";
      wp_list_categories('orderby=id&show_count=0&title_li=
      &use_desc_for_title=1&child_of='.$this_category->cat_ID );
      echo "
    ";
    }
    } ?>

    In plain english this is what happens.

    is the category 'illinois-bars' ?
    If it is
    then display all the subcategoris for the category 'illinois-bars'
    which results in links that look like this:
    sub-cat 1
    sub-cat 2
    sub-cat 3 ...and so on

    I want this to happen

    is the category 'illinois-bars' ?
    If it is
    then display all the subcategoris for the category 'illinois-bars'
    which results in links that look like this:
    sub-cat 1?r_sortby=highest_rated&r_orderby=desc
    sub-cat 2?r_sortby=highest_rated&r_orderby=desc
    sub-cat 3?r_sortby=highest_rated&r_orderby=desc
    ...and so on

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 3 years ago by greenapplewebs
  • This topic is not resolved
  • WordPress version: 3.0.1