Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1232091

    Hi all,

    Is there a way to exclude a single post from a post slider? I already understand about offset. I’m wanting to target a specific post for exclusion within the category.

    Thanks!

    #1232095

    Among the faq’s is on default : how to exclude the current post from post slider when you show a post slider on a single post. But this is not the thing you like to know?

    #1232097

    @Guenni007 Thank you. That might work. Can you please tell me how to exclude the current post from the post slider? Or are you saying that is default behavior?

    #1232100

    no – what i like to say is that this is a common question – a standard question on postslider : so if you got a post-slider in a single post – to show other posts – or related post – but you do not want to have the same post in the slider – add this to your child-theme functions.php:

    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');
    • This reply was modified 4 years, 3 months ago by Guenni007.
    #1232107

    Perfect! Just what I needed.

    Thank you so much!

    #1232119

    Hi,

    I’m glad this was resolved. If you need additional help, please let us know here in the forums.

    Best regards,
    Jordan Shannon

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Exclude Post from Post Slider?’ is closed to new replies.