Plugin Author
Gantry
(@gantry)
Hi,
I’m very sorry for late reply. Do you still need support with this topic?
Thanks,
Jakub
Thread Starter
Theo
(@dubeux)
Hi,
I’m the one to apologize – for some reason I haven’t noticed this reply.
Yes, I still have that issue. If someone can point me the direction to solve it, I’d be very grateful.
Plugin Author
Gantry
(@gantry)
What do you mean by current post? You’d need to define which one is “first” for you. The newest one in choosen category?
Thread Starter
Theo
(@dubeux)
This page is actually a post, called Fazenda Campo Verde. The WordPress Posts particle, at the bottom, list other posts, but repeats this one. Is there a way for the particle to exclude the current post from it?
Plugin Author
Gantry
(@gantry)
Yes, there is, but it requires modifying WordPress posts particle. I’m currently out of my hometown but if you’ll wait till monday I’m gonna prepare a code for you.
Sounds good?
Thread Starter
Theo
(@dubeux)
Sounds no less than amazing, thanks a lot.
Plugin Author
Gantry
(@gantry)
Allright, here is the code that I promised 🙂 Firstly you have to copy the wp-content/plugins/gantry5/engines/wordpress/nucleus/particles/contentarray.html.twig to the wp-content/themes/g5_helium/custom/particles/
Next step is to edit that TWIG file and replace this code :
{# Query Posts #}
{% set query_parameters = {
'cat': filter.categories|replace(' ', ','),
'posts_per_page': limit.total|default('-1'),
'offset': limit.start|default('0'),
'orderby': sort.orderby,
'order': sort.ordering,
'ignore_sticky_posts': sticky_posts
} %}
with this :
{# Query Posts #}
{% set current_post = [wordpress.call('Timber::get_post').ID] %}
{% set query_parameters = {
'cat': filter.categories|replace(' ', ','),
'posts_per_page': limit.total|default('-1'),
'offset': limit.start|default('0'),
'orderby': sort.orderby,
'order': sort.ordering,
'ignore_sticky_posts': sticky_posts,
'post__not_in': current_post
} %}
This should ignore the current post.
-
This reply was modified 8 years, 11 months ago by
Gantry.
Thread Starter
Theo
(@dubeux)
Worked like a charm, thank you very very much.
.
In case someone else looks for this, in my (hydrogen theme) install, the original twig file was here:
wp-content/plugins/gantry5/engines/wordpress/nucleus/particles/contentarray.html.twig
And I’ve copied it to my child theme:
wp-content/themes/child-theme/custom/particles/contentarray.html.twig
.
Thanks again, that was really helpful.