Re: Remove “Category Archives” from a category page header

#1050
admin
Participant

Hello,
You may use the following code snippets to satisfy your requirements,

Edit File

Write any of the following code snippet in the prana/functions.php file,

Code Snippet

[PHP]/** Exclude categories on your main page */

function kamn_exclude_category( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( ‘cat’, ‘-2,-6’ );
}
}
add_action( ‘pre_get_posts’, ‘kamn_exclude_category’ );[/PHP]

[PHP]/** Specific categories on your main page */
function kamn_specific_category( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( ‘cat’, ‘5,2’ );
}
}
add_action( ‘pre_get_posts’, ‘kamn_specific_category’ );[/PHP]

Reference:

http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts

Thanks