• Hi,

    I am trying to use the alm_query_args_{id} filter, it does not seem to be running.

    Here is my shortcode [ajax_load_more id="led" container_type="div" post_type="led_lighting" posts_per_page="12" pause="true" scroll="false" progress_bar="true" progress_bar_color="#D61F2" images_loaded="true" button_label="Load More" button_loading_label="Loading Products"]

    Here is my function

    function my_led_listing($args){
      $terms = $_GET['series'];
    if ( $terms ) {
        $args['tax_query'] = [
            [
                'taxonomy' => 'led_lighting_category',
    			'field' => 'name',
                'terms' => $terms,
            ]
        ];
    }
    // Append our tax-query if we have terms. Make sure it is a valid string or array
    $terms_2 = $_GET['prod_cat'];
    if ( $terms_2 ) {
        $args['tax_query'] = [
            [
                'taxonomy' => 'led_product_category',
    			'field' => 'name',
                'terms' => $terms_2,
            ]
        ];
    }
    // Append our tax-query if we have terms. Make sure it is a valid string or array
    $terms_3 = $_GET['watts'];
    if ( $terms_3 ) {
        $args['tax_query'] = [
            [
                'taxonomy' => 'led_watts_category',
    			'field' => 'name',
                'terms' => $terms_3,
            ]
        ];
    }
    // Append our tax-query if we have terms. Make sure it is a valid string or array
    $terms_4 = $_GET['efficacy'];
    if ( $terms_4 ) {
        $args['tax_query'] = [
            [
                'taxonomy' => 'led_efficacy_category',
    			'field' => 'name',
                'terms' => $terms_4,
            ]
        ];
    }
    // Append our tax-query if we have terms. Make sure it is a valid string or array
    $terms_5 = $_GET['color_temp'];
    if ( $terms_5 ) {
        $args['tax_query'] = [
            [
                'taxonomy' => 'led_color_temp_category',
    			'field' => 'name',
                'terms' => $terms_5,
            ]
        ];
    }
      return $args;
     
    }
    add_filter( 'alm_query_args_led', 'my_led_listing' );
Viewing 1 replies (of 1 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Hi ,
    The issue here is likely the reference to $_GET.
    $_GET will be null in the filter.

    To get querystring values in the filter you need do something like the following:

    function my_led_listing($args){
       $querystring = $_SERVER['HTTP_REFERER'];
       parse_str($querystring, $output);
       //print_r($output);
    }
    add_filter( 'alm_query_args_led', 'my_led_listing' );

    $output will provide you with a parse array of querystring values and you will need to further parse them from there.

    Hope this helps somewhat.

Viewing 1 replies (of 1 total)

The topic ‘Post query hook not working’ is closed to new replies.