Nestd post grid inside Articles

hello15
Sep 13, 2018 11:49 PM 1 Answers General
Member Since Aug 2018
Subscribed Subscribe Not subscribe
Flag(0)
I have a grid of articles selected by category. If one of these articles have another post grid inside, i get an HTTP ERROR 500. How can i solve this?Thank you
    2 Subscribers
    Submit Answer
    Please login to submit answer.

    1 Answers
    Sort By:
    Best Answer
    0
    PickPlugins
    Sep 13, 2018
    Flag(0)

    Welcome to our forum.

    Yes, post grid inside another post loop will create infinte loop that casue 500 http error.

    you need to exclude current post id in pos grid query via filter hook, please see the fist example code in documentation

    Filters – post_grid_filter_query_args

     

    I hope this way your issue will solved.

    Regards

    function post_grid_filter_query_args_extra($query_args){
        
      $current_post_id = get_the_ID();
      
      $extra_query = array (
    
          'post__not_in' => array($current_post_id),
    
          );
    
      return array_merge($query_args, $extra_query);
      }
    
    add_filter('post_grid_filter_query_args','post_grid_filter_query_args_extra');

     

    Sign in to Reply
    Replying as Submit