Last active
September 25, 2024 03:17
-
-
Save mennwebs/9f4dce6df24f3811920bcb8e782c9481 to your computer and use it in GitHub Desktop.
Add Blog CPT to category archive
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 | |
// Add Blog CPT to category archive | |
add_action('pre_get_posts', 'blog_set_category'); | |
function blog_set_category($query) | |
{ | |
if (is_category() && !is_admin() && $query->is_main_query()) { | |
$query->set('post_type', 'blog'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment