Refine search results using WP_Query

You need to just merge the current query for the search with the part you want to add which you came close to doing already. I assume you have a custom taxonomy called media and you specifically want to leave out posts with the term media (like a term found in a tag or category) … Read more

Order posts using a custom array

You would need to build your own query and pass it to query_posts i.e. if your array of post ids is: array (10,21,1) // corresponding to post ids. then you can query this way: select * from wp_posts where `ID` in (10, 21, 2) order by field(ID,10,21,2) This will give you a result set in … Read more

WP_Query on custom taxonomy works fine but fails if run through wp_ajax_

I don’t see your call to the ajaxurl in your code. Are you actually getting an ajax response? Try this javascript: jQuery(document).ready( function($) { $(“a.getviews”).click( function() { var td = $(this).parent(); /* only fetch results once */ $(this).unbind(‘click’).bind(‘click’, function(){return false;}); // replace button with loader $(td).html(‘<span class=”loader”></span>’); $.ajax({ type: ‘POST’, url: ajaxurl, data: { action: … Read more

Meta box dropdown of custom posts

What I would do is just create a custom taxonomy type to share between both custom post types that are dynamically created when a new post of the Clients type is created with the same title, then you can associate them without any custom meta handling.

Sorting By Custom Posts With Attachments

Surprisingly, WordPress does not make it very straightforward. Even though lots of people have had similar questions on the wordpress.org forums, I believe yours is unique in that you want to keep the order and sort. This is by no means quality code, but does exactly what you’re looking for. class WP_Query_Custom extends WP_Query { … Read more