Specific post to only category

hi, Thanks a lot for this amazing theme and support you guys are providing, till now i have resolved every issue using your support forum .

On my Blog i want some post should only appear to their category instead on showing it on home page as latest post . By default every new post shows on blog page .

if my post A belongs to category Z , then i wan this post should only be accessible only through category Z not as a latest post . There are some plugins which gives this functionality to restrict post to only categories and blog page . If its possible without any plugin can you help me .

Thank you once again for this wonderful theme .

Resolved it using this code in functions.php file .

function exclude_category($query) {
	if ( $query->is_home() ) {
		$query->set( 'cat', '-xx' );
	}
	return $query;
}
add_filter( 'pre_get_posts', 'exclude_category' );

Can you suggest which code should be edited in index file using loop method to achieve this functionality . Tried to look on code but seems difficult for me to make changes . sorry for this noob question but i am trying to learn different method .

Thanks

Hi @skartikay,

I hope you are well today and thank you for your question.

Awesome great to see you got that resolved.

Can you suggest which code should be edited in index file using loop method to achieve this functionality . Tried to look on code but seems difficult for me to make changes . sorry for this noob question but i am trying to learn different method .

The content of index file is displayed using query_posts function but you should never use query_posts anymore and best way to alter this loop is using pre_get_posts which you did above.

Find more information about this on the following page.

Have a fantastic day!

Best Regards.
Movin