Adding a parameter to the default query

I think the cleanest method here is just run a custom query, get the ID and then remove that post from the main query with post__not_in. You can additionally run a query inside a function and then call the function in your featured section and in pre_get_posts. There is another way, using a global to … Read more

Sort users by “birthday” using WP_User_Query

User Meta Query with RLIKE: If the birth date is stored like dd/mm/yyyy, in the user meta, then you could find all August birthday users with the following meta query: ‘meta_query’ => [ [ ‘key’ => ‘birthday’, ‘value’ => ‘/08/’, ‘compare’ => ‘RLIKE’ ], ] You could also consider storing the birthday month additionally in … Read more

How to use WP_Query to display many posts?

The p (post) paremeter for WP_Query accetps a single value only: $args = array( ‘p’ => 100 ); For multiple posts use post__in and pass an array of post ids: $args = array( ‘post__in’ => array(100, 102, 105) ); See Post & Page Paremters for further clarification.

How to pass many ids in post__in?

Don’t concatenate your id values into a comma separate string otherwise you will have to explode() by comma delimiter which is pointless, instead, if you are getting IDs from some other business logic as evidenced in your iteration over $rows, then build an array of IDs as per the following example: $ids = array(); foreach … Read more

Date and Category query with filter

I was going about this the wrong way around. I needed to allow the user to select the date first and then the category. I also needed to make the dropdown boxes auto select, so that the date search is performed first taking the user to the date archive and then the user can select … Read more