• Resolved pulaoo

    (@pulaoo)


    Hi,

    I am using the load more function through elementor pro and figured out today that it creates a duplicate of my post after the load more has been clicked.

    Does anybody have a way to fix it?

    Thank you

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • I have the same issue. Also, it removes some posts to be shown.

    I assume, after the load more feature has been triggered, some posts will be shown again (duplicated) instead of showing the remaining posts that have not been rendered yet.

    Plugin Author dudaster

    (@dudaster)

    Working on a fix but you can alter the query using this method:
    https://developers.elementor.com/custom-query-filter/

    And you can filter the posts that are shown.

    Also are there more then one posts widgets on page?

    Would you mind elaborate on this? Her is what I did but not working. Please let me know how to make it work:

    Snippet:
    // Showing multiple post types in Posts Widget
    add_action( ‘elementor/query/my_custom_filter’, function( $query ) {
    // Here we set the query to fetch posts with
    // post type of ‘custom-post-type1’ and ‘custom-post-type2’
    $query->set( ‘post_type’, [ ‘post’ ] );
    } );

    and under Edit Post > Query > Query ID I put this:
    my_custom_filter

    Is that right?

    thanks

    • This reply was modified 4 years, 2 months ago by esalari.

    Also, is it possible to remove the change in the URL for pagination? In other words, when the user scrolls down, the URL changes from mysite.com/ to mysite.com/page/1/ and mysite.com/page/2/ and so on. This can cause some issues when users refreshes the page and the user will see a 404-page error. So, it would be great to disable page URL change/update on the scroll.

    Thanks

    Also tried this in my Child Theme with no luck:

    add_action(‘elementor/query/my_custom_filter’, function($query){
    $query -> set(‘order’, ‘random’);
    });

    Plugin Author dudaster

    (@dudaster)

    you can use this custom query filter hook:

    // Adding a custom filter to post widget
    add_action( 'elementor/query/uniq_rand', function( $query ) {
    	// Here we set the query 
    	if($query->query['paged']==1 || !isset($_SESSION['rand_seed'])) {
    		$_SESSION['rand_seed'] = rand();
    	}
    	$query->set( 'orderby','RAND('.$_SESSION['rand_seed'].')' );
    } );

    In Posts Widget in Custom Query ID you set: uniq_rand .
    Also make sure you have this line on the top of the functions.php for this hook to work: session_start();

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Load More function create duplicate post’ is closed to new replies.