Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • I am using jetpack version 4.3.1. My fix is in the below, so far so good.

    add_filter( 'infinite_scroll_query_args', 'jetpack_infinite_scroll_query_args' );
    
    function jetpack_infinite_scroll_query_args( $args ) {
    	
        // Customize the ordering
        $args['orderby'] = 'meta_value_num';
        $args['meta_key'] = 'YOUR_META_KEY';
        $args['order'] = 'DESC';
    
        try{
        	// Get the start page, if the request is from 1st page, it will be 0,  and then no need to do decrement.
        	$startPage = intval($_POST['query_args']['paged']);
        	if($startPage != 0) $startPage--;
    
            // Adding $args is to avoid the people making infinite scrolling request in
            // non 1st page
        	$currentPage = ($args['paged'] + $startPage);
    
        }catch(Exception $x){
            // If error exists, I just use back the paged argument
        	$currentPage = $args['paged'];
        }
    
        // Using offset is used to override the paged args which will be used in WP_Query
        $args['offset'] = $args['posts_per_page'] * $currentPage;
        
        return $args;
    }

    If you will use infinite scroll for custom post type with meta_key ordering, you have to change the query params in ‘pre_get_posts’ hook too to make the post display consistent.

    Thread Starter alextsoi

    (@alextsoi)

    Sorry for the late response, and my version (3.2.7) is older than 3.3.4, so the problem I mentioned may be fixed in newer version. Sorry again for helping me checking the code for a long time ><

    Please feel free to close the ticket. Thank you very much

    Thread Starter alextsoi

    (@alextsoi)

    The problem is the value of a variable called $ajax_url is wrong in line 236 of the attached file. The ajax request URL return 404 such that it makes the plugin unable to work.

    I saw the language slug is added in the $ajax_url, i.e. http://YOUR_DOMAIN.com/en/admin_ajax.phpXXXXX, and if I remove the language slug, the ajax request will be processed successfully. Since I don’t have time to check on the details, but I think the WPML may did something while generating the variable $ajax_url.

    P.S. my default website language is not english, but chinese, so the site may automatically add some language slug to the URL.
    P.S. only line 236 of the attached file ( appearance.php ) is changed, otherwise are same as the RealFaviconGenerator plugin.

    Temp link: https://github.com/alextsoi/temp-fix-RealFaviconGenerator/blob/master/appearance.php

    Thread Starter alextsoi

    (@alextsoi)

    I am sorry, I just saw your reply. I will upload the sample code of the file with incorrect ajax url within today. For WPML, I think you may need to ask WPML team since there are multiple plugins for WPML.

    My simple guess is “WPML probably added a function to a hook for building url”.

Viewing 4 replies - 1 through 4 (of 4 total)