• I have Wp blog that need to receive a custom paramter on category page for filter the posts like my rule.

    For example: http;//mysite.com/category/teste?myvar=ABC

    How can I get the myvar from URL? I tried a lot of examples on the web, but no one works for the category page.

    Thanks!

Viewing 1 replies (of 1 total)
  • Thread Starter marcoslavorato

    (@marcoslavorato)

    Solved with:

    add_filter( 'category_link','append_parameter', 10, 2 );
    
        function append_parameter( $link, $my_parameter ) {
        $my_parameter = $_GET['sort']; //get sort value
        if ( isset($my_parameter) ) {
            $link = add_query_arg( 'sort', $my_parameter, $link );
        }
            return $link;
        }
Viewing 1 replies (of 1 total)

The topic ‘Custom URL parameter’ is closed to new replies.