Can't see the list of Global Blocks

Hello! I created a new Global Block, but I’m not able to see it in the Global Blocks section. I can add it by editing any page and selecting Global Block from the elements, but I’m not able to see the entire list on Global Blocks page.

Hello @malavkarkar

Thanks for writing to us.

I checked your site it seems that there is an issue with your child theme, I would suggest you please deactivate the child theme and activate the parent theme than check the Global block. Please have a look at the given screenshot in the secure note.

Please note we don’t provide customized child theme support. It is out of the support scope.

Thanks for understanding

Hi @prakash_s

Thank you for bringing this up. I investigated further and found out that it’s a particular code in functions.php that’s causing this issue. I added this code to only display blog posts in search results and omit other results. This is the code.

function searchfilter($query) {
if ($query->is_search && !is_admin() ) {
$query->set(‘post_type’,array(‘post’));
}
return $query;
}

add_filter(‘pre_get_posts’,‘searchfilter’);

Can you please check if anything is wrong with it?

Hi @malavkarkar,

The is_admin() conditional tag only checks if the Dashboard or the administration panel is attempting to be displayed. Try current_user_can() instead, the code will look like the following.

function JustPostFilter($query) 
{
    if ($query->is_search && !current_user_can('administrator') ) 
    {
        $query->set('post_type', 'post');
    }
    return $query;
}
add_filter('pre_get_posts','JustPostFilter');

Please remember that the above code will work if copied as it is and doesn’t conflict with any existing style.
Please note that the code provided serves only as a guide to help you get started custom coding on your own if there’s no option offered in our theme or the products we bundle.
We really do not provide support for custom codes which means we can’t fix it in case it conflicts with something on your site nor will we enhance it.

Thanks

Amazing, that worked! Thank you so much.

You are most welcome @malavkarkar

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.