Support

Account

Home Forums General Issues Issues with pre_get_posts() and get_field() Reply To: Issues with pre_get_posts() and get_field()

  • The problem is that your changes to the query are effecting every query, including those to get attachments, fields, field groups, anything that is appearing on the home page. You need to narrow down what you are applying this to more than you have.

    For example, if this is to alter the query that shows the archive list of “Posts” in order to add “Tweets” then you should check to make sure that the post type being queried is in fact “post”

    for example:

    
    if ( !is_admin() && is_home() && 
          isset($wp_query->query_vars['post_type'] && 
          $wp_query->query_vars['post_type'] == 'post') {