Last active
June 22, 2017 21:56
-
-
Save NichlasB/47f6aa506477724d0beb042af6798659 to your computer and use it in GitHub Desktop.
Display Chosen Categories on WordPress Blog Page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly | |
/** | |
* display-chosen-categories.php | |
*/ | |
//* Display only chosen categories on blog page | |
function cf_display_chosen_categories( $query ) { | |
if ( $query->is_home() && $query->is_main_query() ) { | |
$query->set( 'cat', '5 3'); | |
} | |
} | |
add_action( 'pre_get_posts', 'cf_display_chosen_categories' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Exclude chosen categories from blog page: https://gist.github.com/NichlasB/e50134cc6235dc1b91c4aa6537f0e841