Custom Order in WP Query

Chain the filters: if ( ‘include’ == $query->query_vars[‘orderby’] ) add_filter( ‘posts_orderby’, /* … */ ); And in your orderby filter use: remove_filter( current_filter(), __FUNCTION__ );

How to create an archive for all posts that do not have a post format?

For me I’d used a little different approach: use an endpoint to create an url like http://example.com/no-formats/ hooking pre_get_posts to set the proper query if needed filter template_include to force WP to use home.php instead of duplicating it No more. add_action(‘init’, ‘add_no_format_endpoint’); function add_no_format_endpoint() { add_rewrite_endpoint( ‘no-formats’, EP_ROOT ); } add_action(‘pre_get_posts’, ‘handle_no_format’); function handle_no_format( $q … Read more

Comparing arrays with meta_query in pre_get_posts

The ACF Documentation recommends checking the values individually rather than simultaneously using an array. The following code is from the ACF Documentation for the Checkbox field type: http://www.advancedcustomfields.com/resources/field-types/checkbox/ /* * Query posts for a checkbox value. * This method uses the meta_query LIKE to match the string “red” to the database value a:2:{i:0;s:3:”red”;i:1;s:4:”blue”;} (serialized array) … Read more

WP_Tax_Query with post_tag not working

I did get the thing working, though I’m not entirely sure how. I made two changes: Removed the “convert array to Tax_Query object” step (which I only put in because using an array wasn’t working before) Added a direct assignment of the array to the $query object (rather than just using the set() method). My … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)