2 Loops, Only Displaying 1 Loop in Both Loops

You can’t add the pre_get_posts action right before the loop. You HAVE to do it in functions.php. It has to be set before the site actually queries the db to set up the loop which happens before your template file is loaded. What you are doing is looping through the exact same query twice, because … Read more

Custom search form to display users only

I am not going to write your form for you, but create a form and submit it to a page to do the processing, or use the AJAX API. Then use WP_User_Query to actually search for users. It is a very WP_Query-like class that should let you do everything you want including search for user … Read more

Using pre_get_posts to filter one loop in a multiloop archive

Add the filter where you need it and remove it afterwards. add_action(‘pre_get_posts’,’blog_filter’); // your query; presumably WP_Query // your first loop remove_action(‘pre_get_posts’,’blog_filter’); // another query; presumably WP_Query // your second loop You can also make your action self-removing: function blog_filter($query) { remove_action(‘pre_get_posts’,’blog_filter’); if ( !is_admin() && $query->is_main_query() ) { if ($query->is_post_type_archive(‘rg_blog’)) { $query->set(‘post_type’, ‘post’); } … Read more

Pulling current post/page data into header.php

Main query is actually processed before template is loaded, so data is available in header (if a little less convenient to use). You don’t actually need loop, get_the_ID() should give you ID for the queried object and most template tags have version that will return you results for that specific ID. Loop would work just … Read more

Sort Posts By Category?

You have the orderby parameter in your query but you are missing the companion order. This gives ascending/descending rule to the sortation. WordPress Codex reference