Look at your filter:
apply_filters('change_number_of_posts_home', $posts_per_page)
The value being passed to it is $posts_per_page
, so of course they can’t change $number
.
If you want only the number to be filtered then that’s the part that should have the filter applied:
$number = apply_filters('change_number_of_posts_home', 3 );
Then the query can just look like this:
$wp_query->query( 'post_per_page=" . $number . "&paged='.$paged);
They’re not relevant to the question, but some other things I noticed about your code:
- You shouldn’t be overwriting
$wp_query
like that. Just use a new variable for your custom query. - You can pass the arguments to
new WP_Query( $args )
rather than needing to run->query()
as a separate step. - The code would be easier to read if you pass the arguments as an array, rather than a query string.
- Each individual post should be an
<article>
. You’re wrapping all the posts in a single article tag.