We're merging with GenerateBlocks! Learn more here.

[Resolved] AJAX Pagination loading too much; another link for button

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support AJAX Pagination loading too much; another link for button

Viewing 15 posts - 1 through 15 (of 24 total)
  • Author
    Posts
  • #35814
    Stephan
    Participant

    Hello team,

    I have three questions regarding using the WP Shop Post Pro Plugin.

    On my front page, I have two shortcodes for two lists. The first one shows WooCoomerce products (all), the second one WooCommerce products of a specific category. When I now click the “Show more” button, the first shortcode loads more entries, but also the second although the chosen category does not have so many products in it – just some random products get loaded. Is the idea not to use two shortcodes on the same page with pagination? I already stopped all other plugins to see if there are some problems, but it seems to change the behavior.

    Then I would like to make the “load more” button a bit bigger, like the whole width of the posts and translate it. Is that possible?

    And most importantly, I would like to pass on the affiliate link of a WooCoomerce product into the “read more” button link of a content box, so a click sends you directly to the external website, whereas picture and headline to the WooCommerce product on the site (working already perfectly).

    Thanks for your support,
    Stephan

    #35858
    elvin
    Moderator

    Hi Stephan,

    On my front page, I have two shortcodes for two lists. The first one shows WooCoomerce products (all), the second one WooCommerce products of a specific category. When I now click the “Show more” button, the first shortcode loads more entries, but also the second although the chosen category does not have so many products in it – just some random products get loaded. Is the idea not to use two shortcodes on the same page with pagination? I already stopped all other plugins to see if there are some problems, but it seems to change the behavior.

    Multiple queries on a same page goes haywire when either of the list has pagination with offset OR AJAX pagination(show more). It’s quite tricky to fix and it’s one of the major things the dev team is trying to fix on the next version. There’s no fix for this at the moment, unfortunately.

    Then I would like to make the “load more” button a bit bigger, like the whole width of the posts and translate it. Is that possible?

    This can be done with CSS:

    .wpsp-load-more a {
        width: 100%;
    }

    Here’s the PHP snippet for the translation:
    https://wpshowposts.com/support/topic/ajax-load-more-translation/#post-25436

    And most importantly, I would like to pass on the affiliate link of a WooCoomerce product into the “read more” button link of a content box, so a click sends you directly to the external website, whereas picture and headline to the WooCommerce product on the site (working already perfectly).

    You can change the link of he read more button through wpsp_read_more_output filter.

    add_filter( 'wpsp_read_more_output', function( $output, $settings ) {
    
    if( 1234 === (int) $settings["list_id"]){
        return sprintf(
            '<div class="wpsp-read-more"><a title="%1$s" class="%4$s" href="%2$s">%3$s</a></div>',
            the_title_attribute( 'echo=0' ),
            esc_url( get_permalink() ),
            __( 'Read more', 'wp-show-posts' ),
            esc_attr( $settings['read_more_class'] )
        );
    }
    
    return $output;
    }, 10, 2 );

    Change 1234 to the list ID of the WPSP w/ the WooCommerce listing.

    #35921
    Stephan
    Participant

    Hi elvin,

    thanks for your answer!

    I understand the situation with the two shortcodes and now just use a WooCommerce one for the second. That works for the time being.

    The width of the button also works, thank you!

    The translation of the button works – but only until you press it for the first time. Then it is English again (only the first translation, the after-click translations stays translated).

    The code for the affiliate link I insert with the Snippets plugin. But as soon as I activate it, I get a critical error. Do you have any idea what could be wrong?

    Thanks again,
    Stephan

    #35927
    elvin
    Moderator

    For the translation, try this:

    add_filter( 'wpsp_ajax_load_more', function($output){ 
    	$output = __(  'Показать еще', 'wp-show-posts-pro' ); 
    	return $output; 
    });
    
    add_filter( 'wpsp_ajax_loading', function($output){ 
    	$output = __(  'Загрузка...', 'wp-show-posts-pro' ); 
    	return $output; 
    });

    The code for the affiliate link I insert with the Snippets plugin. But as soon as I activate it, I get a critical error. Do you have any idea what could be wrong?

    Not sure what you mean. can you share the code you’ve added?

    #35941
    Stephan
    Participant

    Thank you, that works for the translation!

    I wanted the “Read more” more link directly linking to the product link of the WooCommerce link. You gave me this code:

    add_filter( 'wpsp_read_more_output', function( $output, $settings ) {
    
    if( 1987 === (int) $settings["list_id"]){
        return sprintf(
            '<div class="wpsp-read-more"><a title="%1$s" class="%4$s" href="%2$s">%3$s</a></div>',
            the_title_attribute( 'echo=0' ),
            esc_url( get_permalink() ),
            __( 'Read more', 'wp-show-posts' ),
            esc_attr( $settings['read_more_class'] )
        );
    }
    
    return $output;
    }, 10, 2 );

    But if I add this, I get an error.

    #35964
    elvin
    Moderator

    I’ve tested the same code on my site and it works fine. Can you share the error you’re getting?

    #35984
    Stephan
    Participant

    The error is that everything vanishes from the homepage, except for the menu and one entry of the WP Show Posts which also misses the link button.

    I have all Plugins deactivated except for Code Snippets, GenerateBlocks, GP Premium, WooCommerce, WP Show Posts and WP Show Posts Pro.

    Would you like to see the site?

    #36001
    elvin
    Moderator

    Can you link us to it?

    You can send it through our contact page if you wish to keep it private. – https://wpshowposts.com/contact/

    #36097
    Stephan
    Participant

    Do you need some more information? I sent you the link via email (the second one).

    #36100
    elvin
    Moderator

    Do you need some more information? I sent you the link via email (the second one).

    I’ve checked through the system and it didn’t seem to receive the second email. (Last email received was December 7th linking to “doobeedoo” but there’s no login link)

    While waiting:

    The code I provided for WooCommerce link is an example. It’s not the direct solution.

    I’m not exactly sure what you meant by “the product link of the WooCommerce link” as I’m not sure what you meant by “WooCommerce Link”. (The read more link already links to the single product page.)

    That’s why I gave the filter code so atleast you can play around with the line esc_url( get_permalink() ) and change it to where you want to point it.

    #36107
    Stephan
    Participant

    Hello Elvin,

    seems that the mail got lost. I sent it again. The WP installation is just a subdomain install under /de.

    Yes thank you for the code, I just need a hint how to get the right link. The read more link now points to the single product page, that is correct. I would like to have it link to the affiliate link directly (so as if to click the buy button on the single product page). Is that possible?

    Thanks again,
    Stephan

    #36110
    elvin
    Moderator

    I still don’t see the email on the system.

    Can you make sure the email being used is correct? Or perhaps try sending a new email thread? https://wpshowposts.com/contact/

    Note: If you know what the affiliate link is, you can make the change on the code yourself so we can skip the back and forth w/ the email. 😀

    #36117
    Stephan
    Participant

    Hi Elvin,

    sorry for the fuss. No idea whats going on. The password/name you have, this is the address: https://doobeedoo.deals/de/wp-admin/

    Of course I tried it by myself the last days, but I just don’t get it. I am completely stumped.

    Lots of thanks for your help,
    Stephan

    #36122
    elvin
    Moderator

    Thanks, I’m able to access the site now.

    Can you share what affiliate link should be added? So I can modify the code to add it for you. 😀

    #36124
    Stephan
    Participant

    Hi Elvin,

    it is just the code that is on the button of a WooCommerce single product page. In my case it is not the “add to cart” link, but an external affiliate link for each product. So I want these different affiliate links (on the standard button of a WooCommerce product) on the Show Posts “read more” button, so as if clicking on the button on the single product page.

    Thank you!

Viewing 15 posts - 1 through 15 (of 24 total)
  • You must be logged in to reply to this topic.