Woocomerce – Order products by float attribute in archive pages

OK… First of all, `$query->set( ‘orderby’, ‘pa_od’ );’ will most probably do nothing. You can’t order by some string and think that WordPress will guess what that is. Here is the list of possible orderby values: https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters If you want to order by custom field, then you have to do it this way: $query->set( ‘meta_key’, … Read more

Modify author archive query to combine two queries

The only way that I’ve found to override the main author archive query in a way that will include posts that aren’t created by the specified user is by using the posts_where filter. For example: $post_ids = function_that_gets_desired_post_ids(); add_filter(‘posts_where’, function($where) use ($post_ids){ $post_ids = array_map(function($id){ return (int) $id; }, $post_ids); $in = implode(‘,’, $post_ids); $where … Read more

Why is pre_get_posts hook invoked multiple times?

The pre_get_posts action runs any time posts are queried. This obviously includes the main query for displaying your latest posts or the current page, but it also includes any other time posts are queried. So that would include any use of WP_Query() or get_posts() in a plugin or your templates, any Recent Posts or similar … Read more

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