How WordPress converts URL to $query_string

Check out WP::parse_request() – unfortunately, it was never really designed for public use. You could try this, not sure of the repercussions: global $wp, $wp_the_query; // Grab the request_uri component of the referer URL. if ( ! $url = parse_url( $_GET[‘my_referer_parameter’] ) ) return ‘Oh dear, poorly formed referer.’; // Ewww! Trick WP::parse_request by spoofing … Read more

WordPress query by category, sorted by custom field

I don’t think there’s an easy to sort by three different meta values, and really, I don’t see why you need to in this case. Why not just save the event date in one meta value and sort by that? It makes your query much more efficient (removes two unnecessary joins) and lets you use … Read more

Generating dynamic Tabs with multiple query post loop

You need to do a foreach for the get_the_category Something like: while ($my_query->have_posts()) : $my_query->the_post(); $x = $my_query->current_post + 1; //you can use this to count instead $categories = get_the_category(); foreach($categories as $category) { if ($x == 1) … //rest of your output // remember to us $category->cat_name; instead of what you have above }

Pagination stops at page 6

Trying to use pagination from a different query is always fraught with potential disaster. next_posts_link accepts a second argument, $max_pages, which may solve your issue if you pass it properly: next_posts_link( __( ‘Next’), $idxloop->max_num_pages ); However, the real answer to this question is to adjust your query before the template. Adjusting the default query via … Read more

The correct way to call posts with ajax

As @MatthewBoynes already stated, making a $.post() request for every image might bring some overhead. A maybe better solution would be to grab and cache them, then throw them into your js files using wp_localize_script(). $attachments = get_posts( array( ‘post_parent’ => get_the_ID() ,’post_type’ => ‘attachment’ ,’posts_per_page’ => -1 #,’exclude’ => get_post_thumbnail_ID() // only needed if … Read more

Exclude category from loop not working

Don’t use query_posts(). Use pre_get_posts instead: function wpse82745_filter_pre_get_posts( $query ) { // Only modify the main loop, // and only in the blog posts index if ( is_home() && $query->is_main_query() ) { $query->set( ‘category__not_in’, array( ’13’ ) ); } } add_action( ‘pre_get_post’, ‘wpse82745_filter_pre_get_posts’ ); This callback will exclude category 13 from the main loop in … Read more

wordpress loop and template files

If you look at the template hierarchy for categories you will see it follows: category-{slug}.php category-{id}.php category.php archive.php index.php As Milo says these templates are just using the loop to display what is already queried, so there template itself does not matter outside load order of the hierarchy.