Home › Forums › Pro Support › AJAX Pagination loading too much; another link for button
- This topic has 23 replies, 2 voices, and was last updated 1 year, 9 months ago by
elvin.
-
AuthorPosts
-
November 26, 2021 at 7:08 am #35814
Stephan
ParticipantHello 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,
StephanNovember 28, 2021 at 4:22 pm #35858elvin
ModeratorHi 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-25436And 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.
December 1, 2021 at 11:28 am #35921Stephan
ParticipantHi 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,
StephanDecember 1, 2021 at 4:26 pm #35927elvin
ModeratorFor 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?
December 2, 2021 at 3:41 am #35941Stephan
ParticipantThank 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.
December 2, 2021 at 5:25 pm #35964elvin
ModeratorI’ve tested the same code on my site and it works fine. Can you share the error you’re getting?
December 3, 2021 at 10:42 am #35984Stephan
ParticipantThe 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?
December 5, 2021 at 4:02 pm #36001elvin
ModeratorCan you link us to it?
You can send it through our contact page if you wish to keep it private. – https://wpshowposts.com/contact/
December 13, 2021 at 7:15 am #36097Stephan
ParticipantDo you need some more information? I sent you the link via email (the second one).
December 13, 2021 at 4:09 pm #36100elvin
ModeratorDo 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.December 14, 2021 at 5:39 am #36107Stephan
ParticipantHello 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,
StephanDecember 14, 2021 at 6:44 pm #36110elvin
ModeratorI 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. 😀
December 15, 2021 at 11:45 am #36117Stephan
ParticipantHi 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,
StephanDecember 15, 2021 at 7:46 pm #36122elvin
ModeratorThanks, 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. 😀
December 16, 2021 at 1:48 am #36124Stephan
ParticipantHi 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!
-
AuthorPosts
- You must be logged in to reply to this topic.