fix(query): ensure accurate post type exclusion logic

Updated logic to properly exclude posts from main queries based on theme settings. This change ensures that only posts are excluded when the 'disable_posts' setting is enabled, preventing unintended behavior for other post types.
This commit is contained in:
Kumi 2024-08-03 20:04:41 +02:00
parent bee50a461d
commit 97935f9401
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -1081,8 +1081,8 @@ function exclude_posts_from_queries($query)
{
if (!is_admin() && $query->is_main_query()) {
$disable_posts = get_theme_mod('disable_posts', false);
if ($disable_posts) {
$query->set('post_type', array('page'));
if ($disable_posts && $query->get('post_type') === 'post') {
$query->set('post_type', 'page');
}
}
}