Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1416592

    Hi, I’m using Enfold. I added ‘Blog Posts’ to the bottom of ALL single posts (I call this section “Related Posts”). I’m just showing the last 3 posts. How do I hide the post I’m currently on from this ‘Related Posts” section?

    Example: http://www.mycompany/blog/post2/
    On this page, the “Related Posts” section should hide Post 2. It should only display Posts 1, 3 and 4.

    #1416635

    Hey Celeranttechnologycorp,
    Try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:

    add_filter('avia_post_slide_query', 'avf_custom_post_grid_query');
    function avf_custom_post_grid_query ( $query ) {
      if(is_singular('post')) {
          global $post;
    
          $query['post__not_in'] = array($post->ID);
      }
      return $query;
    }

    Best regards,
    Mike

    #1416787

    Hi Mike, Thank you. This worked. I just had to change the variable so it accounts for my custom post type.
    if(is_singular(‘post’)) {
    to
    if(is_singular(‘press’)) {

    #1416808

    Hi,
    Glad to hear that you have this sorted out, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Hide Post on Single Post’ is closed to new replies.