query_posts
breaks the main query object ($wp_query
) which holds the query object and all relevant query info which breaks all conditional tags and pagination and page functionality, which simply means that it is totally useless trying to use any info regarding the main query object as it was all corrupted by query_posts
resetting the main query.
That is the number one reason one should never ever use query_posts
.
As this is a category page, simply remove the following lines
cat = get_query_var('cat');
$PozCat = get_category ($cat);
//$PozCat->id
query_posts('posts_per_page=-1&cat=".$PozCat->id);
Your category page will work normal again. If you need to alter the main query on your category page, use pre_get_posts
to correctly alter the query variables before the SQL is build to run the main query. The following will return all posts on you category pages
add_action( "pre_get_posts', function ( $q )
{
if ( !is_admin() // Only target front end
&& $q->is_main_query() // Only target the main query
&& $q->is_category() // Only target category pages, change to $q->is_tax() for taxonomy pages
) {
$q->set( 'posts_per_page', -1 );
}
});