• Resolved philipjoshua00

    (@philipjoshua00)


    Hi!
    I just want to ask if there’s a way to filter a Post select dropdown via URL parameter?
    I know you can do that by indicating the categories on the shortcode, but what if I want it be dynamic thru URL param?

    Example:
    abc.com/?cat=apparels
    all post with this category will display on dropdown.

Viewing 1 replies (of 1 total)
  • Plugin Author Markus Wiesenhofer

    (@markusfroehlich)

    Hello!
    Yes you can use the “wpcf7_yourtag_get_posts” filter in your functions.php file.

    For example:

    add_filter("wpcf7_yourtag_get_posts", "filter_dropdown_posts");
    
    function filter_dropdown_posts($post_args)
    {
    	if(isset($_GET['cat']))
    	{
    		$post_args['tax_query'] = array(
    			array(
    				'taxonomy' => 'category',
    				'field'    => 'slug',
    				'terms'    => $_GET['cat'],
    			),
    		);
    	}
    
    	return $post_args;
    }

    Best regards
    Markus

Viewing 1 replies (of 1 total)

The topic ‘Post Select Filter by URL paramater’ is closed to new replies.