As already mentioned, don’t use query_posts()
. Even the WordPress docs state this:
Note: This function isn’t meant to be used by plugins or themes. As
explained later, there are better, more performant options to alter
the main query. query_posts() is overly simplistic and problematic way
to modify main query of a page by replacing it with new instance of
the query. It is inefficient (re-runs SQL queries) and will outright
fail in some circumstances (especially often when dealing with posts
pagination). Any modern WP code should use more reliable methods, like
making use of pre_get_posts hook, for this purpose.
The problems with that function are many, including clobbering the main query which can cause unexpected issues with plugins and theme code and its use increases the number of queries to the database thus negatively effecting the page load time. I suspect the fact that you are clobbering the main query is the cause of your issue.
If this is the main query of the page, then you need:
function pregp_wpse_189739($qry) {
if (is_main_query()) {
$qry->set('post_type','brands');
$qry->set('posts_per_page',99);
$qry->set('order','ASC');
}
}
add_action('pre_get_posts','pregp_wpse_189739');
If it is not the main query then:
$args = array(
'post_type' => 'brands',
'order' => 'ASC',
'posts_per_page' => 99
);
$my_query = new WP_Query($args);
if ($my_query->have_posts()) {
while ($my_query->have_posts()) {
$my_query->the_post();
// you Loop code
}
}
wp_reset_postdata();
I find get_posts()
to be a bit cumbersome and awkward as you have to code some of the loop yourself, but it should work though not all Loop hooks will fire.