Hiding Pages in Functions.php breaks Jetpack Stats Bar in Admin Bar
-
Hi guys,
I have input this php to hide a number of pages from being displayed in the search function on my site. Unfortunately, it seems to have broken the stats bar in my administrative bar. But, stats still show on my dashboard, and also, if I navigate to the stats page directly. Is there any way to fix this issue?
Here’s what I see: https://rockclass101.com/wp-content/uploads/2019/02/JP-Broken.png
Here is the php in my child theme’s functions.php:
<?php
add_filter(‘pre_get_posts’,’your_custom_search_filter’);
function your_custom_search_filter($query) {
if (!is_admin() && $query->is_search) {
$exclude_ids = array(4968, 2721, 801, 2911, 4879, 4900, 741, 211, 2899, 197, 2922, 300, 2935, 263, 2938, 206, 2941, 306, 2944, 303, 2947, 2905, 223, 191, 2950, 186, 2953, 216, 2908, 4899, 1543, 4613, 2432, 2459, 3074, 3062, 394, 3680, 2548, 4876, 4896, 4573, 4512, 1791, 1246, 1417, 354, 1824, 436, 462, 89, 940, 347, 350, 15, 929, 4827, 4834, 881, 4584, 456, 724, 3681, 1430, 1589, 4877, 4897, 2113, 467, 442, 3682, 959, 610, 814, 397, 3668, 449, 3676, 473, 1148, 1826, 3616, 3035, 4878, 4898, 3527, 608, 2350, 4880, 123, 934, 338, 342, 13, 911, 4829, 4835, 4892, 4872, 20, 4874, 4894, 658, 821, 783, 848, 858, 18, 2383, 507, 3580, 1613, 3673, 1614, 3665, 1612, 3660, 1615, 660, 1809, 1811, 1807, 1805, 1577, 2457, 2437, 3082, 3079, 2716, 268, 2956, 775, 2928, 284, 2959, 145, 2962, 249, 2932, 235, 2925, 1055, 3266, 1563, 5129, 2, 2902, 2112, 4871, 4891, 1226, 1688, 4873, 4893, 356, 1823, 453, 463, 1, 8, 9, 10, 11, 12, 5266, 5857, 5862, 6040, 6096, 6097, 6196, 7047, 7459, 7655, 7656, 7657, 7658, 8362, 8707, 8712, 8638, 8922, 9099, 10059, 10594, 10718, 11236, 11477, 11591, 12875, 13213, 14725, 16044, 17039, 18866, 9551, 20224); //page ids you want to exclude
$query->set(‘post__not_in’, $exclude_ids);
}
return $query;
} ?>The page I need help with: [log in to see the link]
- The topic ‘Hiding Pages in Functions.php breaks Jetpack Stats Bar in Admin Bar’ is closed to new replies.