$query->set with array?
-
i added this to my fuctions to show only posts of type wines to the homepage.
function home_posts( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'post_type', 'wines' ); } } add_action( 'pre_get_posts', 'home_posts' );I also want to do 12 posts per page. I wrote it as below but I get error Warning: Missing argument 2 for WP_Query::set(),
function home_posts( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set(array('post_type' => 'wines', 'posts_per_page' => 12)); } } add_action( 'pre_get_posts', 'home_posts' );What is the correct way to write this?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘$query->set with array?’ is closed to new replies.