• Hi there,

    I am using this code to hide wp_head from certain pages to save on plugin code being generated on pages it doe not need to be on. Is this the correct way to do so?

    <?php
    //Remove wp_head from pages that does not require it.
    if (is_page(home) || (is_page("archive") || (is_page("biog")))) { ?>
    <?php } else { ?>
    <!-- WordPress Shenanigans (Bits & Pieces From WP Plugins)  -->
    <?php wp_head(); ?>
    <?php } ?>

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Probably – but I dont see why you want to remove it – saves you nothing.

    Remove it completely if you feel so confident.

    Thread Starter britneyjackson

    (@britneyjackson)

    ‘saves you nothing’ – Actually it does save me page load time as I have a few plugins that call Ajax etc. Without wp_head page load time is much faster (for my site).

    Here is what is produced by the plugin: https://paste-it.net/public/f753424/html/

    Thanks

    I needed to do something similar and was able to accomplish this by your statement above, thanks!

    However, what if you only want the wp_header() to show up on one page, wouldn’t it be easier to write the php to only call wp_header() for the page you need it for? Sorry, I’m not good with PHP, how would I do this?

    <?php
    //Remove wp_head from pages that does not require it.
    if (is_page(contact) || (is_page(“request”) || (is_page(“home”)))) { ?>
    <?php } else { ?>
    <?php wp_head(); ?>
    <?php } ?>

    Saves you nothing? It needs to be there. WordPress has quite a few filters in the background using it.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Hiding wp_head from certain pages. Isthis right?’ is closed to new replies.