-
AuthorPosts
-
August 3, 2020 at 12:29 pm #1234798
Hello team of Kriesi,
in blog posts we would like to show the other blog posts of the category with Masonry and Magazine (to show what else might be of interest), but we don’t want to display the current blog post in these elements again. Is that possible – to exclude the current blog post?
Thanks for your effort!August 6, 2020 at 6:39 am #1235598Hey MCK,
Thank you for the inquiry.
Yes, this should be possible. We can use the following filter to exclude the current post from the posts element.
function ava_exclude_current_post($query) { if (is_singular('post')) { $exclude = avia_get_the_ID(); $query->set( 'post__not_in', array($exclude) ); } } add_action('pre_get_posts', 'ava_exclude_current_post');
Related thread: https://kriesi.at/support/topic/exclude-post-from-post-slider/#post-1232100
Best regards,
IsmaelAugust 6, 2020 at 10:35 am #1235646Hey Ismael,
sorry and thank you for the effort! I implemented the code mentioned in here https://kriesi.at/support/topic/exclude-post-from-post-slider/#post-1232100 and it worked perfectly!May I add one more question? Is there a way to remove “Archive” from the breadcrumb of the category pages? So that “Home/ Category” is displayed instead of “Home/Archive/Category”? I managed to remove the “Archive” in the posts using the code mentioned in here https://kriesi.at/support/topic/remove-category-from-breadcrumb/#post-426142
add_filter( ‘avia_breadcrumbs_trail’, ‘mmx_remove_element_from_trail’, 50, 2 );
function mmx_remove_element_from_trail( $trail, $args ) {
if ( is_single() ) {
unset ($trail[1]);
}
return $trail;
}It worked out just fine for the blog posts. However, “Archive” is still displayed in the breadcrumb on the category pages. Is there a way to solve this?
Kind regards!
August 10, 2020 at 6:41 am #1236378Hi,
Thank you for the update.
Try to replace the filter with the following snippet to remove the first trail in the breadcrumb on archive or category pages.
add_filter( 'avia_breadcrumbs_trail', 'mmx_remove_element_from_trail', 50, 2 ); function mmx_remove_element_from_trail( $trail, $args ) { if ( is_single() || is_archive() ) { unset ($trail[1]); } return $trail; }
Best regards,
IsmaelAugust 10, 2020 at 3:28 pm #1236445Thanks a lot, Ismael!
When I inserted this, I received an error:add_filter( ‘avia_breadcrumbs_trail’, ‘mmx_remove_element_from_trail’, 50, 2 );
function mmx_remove_element_from_trail( $trail, $args ) {
if ( is_single() || is_archive() ) {
unset ($trail[1]);
}
return $trail;
}When inserting this (without #39), it worked fine:
add_filter( ‘avia_breadcrumbs_trail’, ‘mmx_remove_element_from_trail’, 50, 2 );
function mmx_remove_element_from_trail( $trail, $args ) {
if ( is_single() || is_archive() ) {
unset ($trail[1]);
}
return $trail;
}Do you think the code without #39 is okay too and won’t cause trouble in future theme updates?
Kind regardsAugust 13, 2020 at 3:20 am #1237207Hi,
Thank you for the update.
What do you mean by #39? The filters that you posted above look the same. What did you change?
Best regards,
IsmaelAugust 14, 2020 at 11:01 am #1237742Sorry Ismael, maybe it was a broser issue, but when I copied the code, I had some “#39” in it. Now I can’t see it either. So please close this thread and THANK YOU for your great support!
August 14, 2020 at 3:33 pm #1237856Hi MCK,
Glad we could help :)
If you need further assistance please let us know.
Best regards,
Victoria -
AuthorPosts
- You must be logged in to reply to this topic.