Try it with this in your theme’s functions.php:
function my_home_query( $query ) {
// not an admin page and is the main query
if (!is_admin() && $query->is_main_query()){
if(is_home()){
// show only category id 22 posts on the home page
$query->set('cat', 22);
}
}
}
add_action( 'pre_get_posts', 'my_home_query' );
And change $query->set('cat', 22);
to the correct category ID you want to show on the home page.
@keesiemeijer: thank you, bro … it’s work 😀
Can u tell me which file should i edit.
I am not getting it.
I added the above code and my server went out.
Can u tell me which file should i edit.
your theme’s functions.php.
I added the above code and my server went out.
Where did you put it?
at the end just above the closin of php
Can you paste and submit the full code of your functions.php into a pastebin.com and post the link to it here? see the Forum Rules for posting code and using the pastebin.
Hi Ronak,
It should be working fine and thank Kessiemeijer for answering this question.
Yes, past your code and if still problem then email us by filling in the contact form in http://catchthemes.com
Regards,
Sakin