- Open Your wordpress dashboard
- Select “Appearance” – > theme file editor ->Theme Function ->functions.php
- Add the following code to the file and save the php file.

function custom_homepage_query( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'cat', '29' ); // replace 'category_id' with the ID of the category you want to display } } add_action( 'pre_get_posts', 'custom_homepage_query' );
- Find the category ID by visiting to Posts, and then Categories in your WordPress dashboard.
- Select the category you want to use.
- The ID will be displayed in the URL at the top of the screen, For example in my case, URL is https://mianwalijobs.pk/wp-admin/term.php?taxonomy=category&tag_ID=29, and the given ID is 29.
- Replace ‘category_id’ with the ID of the category you want to display and save it.
- Reload your homepage to see the posts from only your selected category.