Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

does not work in wp_head hook

  • Hi,
    I want to preload an image via <link rel="preload" ...>
    Therefore, I created a wp_head hook and put my <link rel="preload" ...> in there.
    Unfortunately all <link rel="preload" ...> statements are omitted and do not appear in the <head>-element of the webpage.
    <link rel="prefetch" ...> statements are not omitted.

    My wp_head hook looks like this:

    <link rel="preload" fetchpriority="high" as="image" href="xyz" type="image/svg+xml">
    <link rel="prefetch" fetchpriority="high" as="image" href="xyz" type="image/svg+xml">
    <link rel="preload" fetchpriority="high" as="image" href="xyz" type="image/webp">

    And only the <link rel="prefetch" fetchpriority="high" as="image" href="xyz" type="image/svg+xml"> appears in the <head>-element of the webpage.

    I linked screenshots in the private information section.

    Thanks for your help!

  • Hi there,

    It’s not possible for the hook element only show part of the content.

    1. What is the location you set for the hook element?

    2. Do you have cache enabled? If so, can you clear all cache and disable all cache? Including server-level cache.

    Let me know 🙂

  • Hi,
    that is what I thought as well but it seems it is somehow.
    1. complete site
    2. I do not have any cache enabled yet.
    The element responds to changes. If I remove the <link rel="prefetch" ...> statement it is not shown anymore and if I add another <link rel="prefetch" ...> statement I can see that. Only the <link rel="preload" ...> statements are not shown.

  • Hi there,

    Could you provide temporary login credentials for us to check the backend settings?

  • Hi,
    I can provide you with a login to the testing site I used which behaves the same.

  • Hi there,

    i temporarily edited your Hook element, and for testing before each of the link tags i added a HTML Comment of: <!-- PRELOAD HERE -->
    And on the front end i could see ALL 3 of the comments. But only the prefetch link.

    I then run some checks on the HTML to make sure there were no bad characters that could result in them being saninitized out by WP and tested them on my own site. There were no issues with the code and all 3 links were output correctly on my test site.

    Which means the Element Hook is working but something else is stripping out those preload links at a later point. But i cannot tell you what is doing that.

    Permanently delete any old elements in the trash.
    And quick edit all other elements except the Preoads and set them to DRAFT, this will eliminate any conflicts from other elements.
    Disable all other plugins except GP Premium and again test for conflicts

    if the issue persists then you need to look upstream and check with the host to make sure theres no mod security or other server functions that may be removing them.

  • Hi,

    thanks for your help.

    I tried the things you suggested and it did not work.

    I will contact the host and see what they say.

  • Let us know what you find.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.