• Resolved brownaddesign

    (@brownaddesign)


    I see that the Location > Before and After Content is only available if you add specific pages, posts, categories, etc. but can it be made as an option for site wide?

    There are some scripts that instruct you to add immediately after the opening body tag and it would be nice if we could do so site wide vs. either placing it in the footer (against their instructions), or trying to add each page, etc which isn’t a practical approach.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author 99robots

    (@99robots)

    @brownaddesign – The reason the before/after content is is only available on pages/posts/categories is those are the templates that will absolutely use the_content. In most themes, that function is not used on homepage or other custom pages, and therefore would be moot. Hence, just sticking to what we know will work per the WP way of doing things.

    We are looking into how to introduce a before/after <body> placement that is more thoughtful (not just a hack). It’s actually the most common request. Since many new features are being requested, we’re also considering a PRO version for devs and agencies. But for now, trying to keep things free.

    We certainly do agree while the workaround of placing it in the head or footer is not ideal, it does work in 95% of all cases with the same end result. Therefore, this has not been a big hindrance, but definitely not practical.

    Will add this as 1 more upvote for the body tag feature.

    Thread Starter brownaddesign

    (@brownaddesign)

    OK hopefully you can come up with a solution. I, for one, would consider a Pro version should you decide to offer one.

    So if we added code before content using the specific pages option and entering/selecting all of the pages, including “Home” you’re saying that it’s possible that it wouldn’t actually add it to “Home” depending on the theme, correct?

    Is there an easy way to tell if “the_content” is being used, or would we just view page source and look for the code we added, etc.

    Plugin Author 99robots

    (@99robots)

    Great to hear @brownaddesign.

    1] Correct. If the hook doesn’t exist on the page itself, then it cannot show. This is why the must-haves tags like <head>, the_content, <footer> are used. However, we were were waiting for WP to introduce the hook for body AND for mass adoption by theme developers so that we can be truly compliant as hundreds of thousands of sites use this plugin.

    2] Just view source code and check for the snippet. We add a commented HFCM note with the snippet ID for exactly this purpose and for troubleshooting. So it’s easy to identify.

    Hope that helps.

    Hi, I just want to inform in this thread that I have tested https://www.ads-software.com/plugins/insert-headers-and-footers/ plugin and found that it works on inserting any code just after the opening body tag in any situation, weather its home page or any other post.

    Do you mean that due to the conditions you provide for insert code, its not possible to add a custom code, just after the opening body tag ?

    Actually in wordpress their is an action hook available ‘wp_body_open’ – https://developer.www.ads-software.com/reference/hooks/wp_body_open/

    So in my case to insert custom php or anything I utilize this code manually in theme function.php file

    function uni_add_afterbody_file(){
        include_once(get_template_directory() . '/afteropenbody.php') ;    
    }
    add_action('wp_body_open', 'uni_add_afterbody_file', 10, 0);

    so that way you can also put your conditions in that action hook.

    Plugin Author 99robots

    (@99robots)

    @hozefasmile it will be in a future version of HFCM.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Before and After Content – Site Wide?’ is closed to new replies.