You are viewing an old revision of this post, from June 3, 2015 @ 06:18:43. See below for differences between this version and the current revision.

Remove a category from the front-page.php

The correct way to do this is to make use of pre_get_posts which change the query vars just before the main query is executed. Here is an example from the codex to exclude categories from the home page/blog page. For a full list of available parameters and values that you can use with pre_get_posts, visit the WP_Query codex page: [php]function exclude_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'cat', '-1,-1347' ); } } add_action( 'pre_get_posts', 'exclude_category' );[/php]

Revisions

  • June 3, 2015 @ 06:18:43 [Current Revision] by PeterLugg
  • June 3, 2015 @ 06:18:43 by PeterLugg
  • June 3, 2015 @ 06:18:13 by PeterLugg

Revision Differences

There are no differences between the June 3, 2015 @ 06:18:43 revision and the current revision. (Maybe only post meta information was changed.)

Tags: , ,

No comments yet.

Leave a Reply