Passing a URL variable to category.php
-
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 https://www.ads-software.com/category-slug/ I am using the SEO plugin to rewrite https://www.ads-software.com/category/category-slug and remove the /category/ part. Also, the settings formy permalinks are set to this option in the settings menu: ‘https://www.ads-software.com/sample-post/’
Now I need to be able to pass a variable in the URL like:
https://www.ads-software.com/category-slug/?type=VALUE or https://www.ads-software.com/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 https://www.ads-software.com/category-slug/?type=something or https://www.ads-software.com/category-slug/something I get “nothing found” and “Page not found” pages.
How do I properly pass a variable to a category page?
- The topic ‘Passing a URL variable to category.php’ is closed to new replies.