MB Relationships + Elementor Loops
Support › MB Relationships › MB Relationships + Elementor LoopsResolved
- This topic has 4 replies, 2 voices, and was last updated 1 year, 9 months ago by
Marcus Potts.
-
AuthorPosts
-
February 20, 2024 at 8:11 PM #44622
Marcus Potts
ParticipantHi
Do you have an example of an Elementor custom query that will retrieve related posts so I can display them on my CPT page using Elementor Loop grid or carousel.
I have been going round in circles for days.
Thanks
MarcusFebruary 20, 2024 at 10:09 PM #44628Peter
ModeratorHello Marcus,
You can follow an example here https://support.metabox.io/topic/display-mb-view-shortcode-in-an-elementor-loop-template/?swcfpc=1#post-44339
February 21, 2024 at 1:12 AM #44633Marcus Potts
ParticipantHi Peter
Thanks for your speedy response. I have tried to follow the logic in the twig example:
add_action('elementor/query/related_av_solutions', function($query) { $current_av_solution_id = get_the_ID(); if ($current_av_solution_id && get_post_type($current_av_solution_id) === 'av_solution') { $connected_items = MB_Relationships_API::get_connected([ 'id' => 'posts_to_av_solution', 'from' => $current_av_solution_id, ]); if (!empty($connected_items) && !is_wp_error($connected_items)) { $related_post_ids = wp_list_pluck($connected_items, 'ID'); if (!empty($related_post_ids)) { $query->set('post__in', $related_post_ids); $query->set('orderby', 'post__in'); } else { $query->set('post__in', [0]); } } else { $query->set('post__in', [0]); } } }, 10, 1);But it just blows my PHP memory limit. Any further help would be really appreciated.
Thanks
MarcusFebruary 21, 2024 at 10:03 PM #44639Peter
ModeratorHello,
The example in that topic uses the Twig code in MB Views and add the View shortcode to the Elementor Loop Grid, not the PHP code with a callback function.
If it blows the PHP memory limit, you can increase this value https://blog.hubspot.com/website/wordpress-php-memory-limit
If it still doesn't work, we offer a customization service with an extra fee. You can contact us here to get more details https://metabox.io/contact/
February 21, 2024 at 10:43 PM #44644Marcus Potts
ParticipantHi Peter
Thanks again for your response, I had already increased memory to 1024M and it blew it straight away.
I'll look at alternate solutions.
Thanks
Marcus -
AuthorPosts
- You must be logged in to reply to this topic.