WordPress.org

Ready to get started?Download WordPress

Forums

Passing a URL variable to category.php (1 post)

  1. dreamwave
    Member
    Posted 9 months ago #

    While I see this has been discussed over and over .. none of the solutions seem to work for my case:

    I need to pass a url variable to my category.php file. Currently my category page is at http://wordpress.org/category-slug/ I am using the SEO plugin to rewrite http://wordpress.org/category/category-slug and remove the /category/ part. Also, the settings formy permalinks are set to this option in the settings menu: 'http://wordpress.org/sample-post/'

    Now I need to be able to pass a variable in the URL like:

    http://wordpress.org/category-slug/?type=VALUE or http://wordpress.org/category-slug/VALUE

    where "type" is the name of the variable and VALUE is its value

    I have tried using this piece of code in my functions.php file:

    <?php
       add_filter('query_vars', 'parameter_queryvars' );
       function parameter_queryvars( $qvars )
         {
            $qvars[] = 'type';
            return $qvars;
         }
        global $wp_query;
         if (isset($wp_query->query_vars['type']))
          {
            print $wp_query->query_vars['type'];
          }
    ?>

    However, when I try to open http://wordpress.org/category-slug/?type=something or http://wordpress.org/category-slug/something I get "nothing found" and "Page not found" pages.

    How do I properly pass a variable to a category page?

Reply

You must log in to post.

About this Topic