add code for all except admin

[ad_1]

tried this, but seems to not work as expected.

I copied and pasted your code, and it works for me as expected.

In what way is it working that’s not expected?

(The only thing I can think of why the code may not be working at all is if your theme is not calling wp_footer.)

work so good (but just for all) with simply:

add_action('wp_footer', 'insert_js_into_footer');
function insert_js_into_footer() {
    #if ( ! current_user_can('administrator')) {
        ?>
        <!-- my code -->
        <?php
    #}
}

without # simply I can’t see (both for guest in private browser and by admin).

anytime flush litespeed cache but issue remain.

It works fine for me – but without any cache plugin. I suspect that this is the problem for you. Or perhaps another plugin that is interfering with the check. Try deactivating it to find the culprit.

ty. after some test, I think is an issue with incognito mode here in Firefox mobile. I see code like from logged user (I search for login widget and I seen my name also if apparently I’m absolutely not logged in). Maybe an issue with view source plugin. Tomorrow I check from desktop. Ty

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer