Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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!

    #1235598

    Hey 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,
    Ismael

    #1235646

    Hey 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!

    #1236378

    Hi,

    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,
    Ismael

    #1236445

    Thanks 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 regards

    #1237207

    Hi,

    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,
    Ismael

    #1237742

    Sorry 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!

    #1237856

    Hi MCK,

    Glad we could help :)

    If you need further assistance please let us know.
    Best regards,
    Victoria

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