• Hello, thanks again for this great plugin. I am currently using it and trying to make it play it nice with the Bogo multilingual plugin. https://www.ads-software.com/plugins/bogo/

    Bogo allows me to have my posts and pages in different locales, my problem is that right now when I use the AJAX filter, all posts from all locales get fetched and displayed.

    I took a look at the uwpqsf-process-class.php file and saw the uwpqsf_ajax function. I’ve added the “lang” argument to the $args array, but I’ve done it in a static way. How can I set this argument dynamically so that only posts from my current language get displayed?

    I appreciate any help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter boombalaya

    (@boombalaya)

    Hopefully somebody will find this helpful, I hacked into uwpqsf-process-class.php, but would love to know if there is a filter I can apply to my theme, can I override the function named uwpqsf_ajax?

    Using the Bogo Plugin (https://www.ads-software.com/plugins/bogo/):

    Since all pages and posts have a “_locale” custom field defining what language they belong to, I identify the ID of the page where our shortcode is pasted by adding the following variables:

    //EXTRA PARAMETERS ADDED TO GET THE ID OF THE PAGE			
    $url     = wp_get_referer();
    $post_id = url_to_postid( $url ); 
    $locale = get_post_meta( $post_id, '_locale', true );

    Then in the $args for the query, I added the “lang” parameter and assigned the $locale variable to it, like so:

    `$args = array(
    ‘post_type’ => $cpt,
    //LANG PARAMETER ADDED TO PLAY NICE WITH BOGO PLUGIN
    ‘lang’ => $locale,
    ‘post_status’ => ‘publish’,
    ‘meta_key’=> $ordermeta,
    ‘orderby’ => $ordertype,
    ‘order’ => $order,
    ‘paged’=> $pagenumber,
    ‘posts_per_page’ => $number,
    ‘meta_query’ => $get_meta,
    ‘tax_query’ => $get_tax,
    ‘s’ => esc_html($keyword),
    );`
    Now the only posts fetched by the ajax filter are the ones that match the language of the page in which they are being displayed ??

    • This reply was modified 7 years, 11 months ago by boombalaya.
    Plugin Author TC.K

    (@wp_dummy)

    Yes, there is filter for ajax arguments. uwpqsf_query_args

    Usage:

    add_filter('uwpqsf_query_args','injecting_custom_arg','', 4);
    function injecting_custom_arg($args, $id,$getdata){
      //access the $args like above
      return $args;
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[AJAX] Get results for current locale only?’ is closed to new replies.