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 (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Adsense Ad Hook Alignment

  • I am using hooks for adsense ads placements. The issue is in the sidebar area (for Desktop). It is not aligned well.

  • Hi there,

    You are adding 20px margin-left to each GB container in the right sidebar, while your ads do not have the margin-left.

    I would recommend removing the margin-left from the GB containers in the right sidebar, and adding a padding-left to the entire sidebar:

    .inside-right-sidebar {
        padding-left: 20px;
  • It worked on Desktop. Thank you. But it affected mobile as well. Now the mobile sidebars are put inside too much.

    Also, is there a way to put this particular Ad Hook a bit down like top padding for 10px?

    The top ad on mobile is also aligned on the left; it should be centered.

    What code should I include in the Hook to center it or adjust alignments?

  • Hi there,

    Could you edit the hook element like this first:

    <div class="grid-container ad-over-content hide-on-mobile">
    your script here


    <div class="grid-container ad-over-content hide-on-desktop">
    your script here
  • Okay, but I guess first I need to resolve another issue which might be connected. Please see the screenshot:

    On my mobile there is some extra white space (see on the right) if I move the screen to the left. No idea why this happens.

    And when page is loading impages resize to the right dimensions after some time, at first they are centered then they adjust to the proper size.

  • It’s caused by the custom header, the parent container of the header has a margin-right set to -20px on mobile, set it to 0 should fix the issue.

  • Thank you. There is still a bit of a margin left, though almost gone. But humburger icon is positioned more left than I would wanted

    and see how images are placed on the left instead of covering the entire space:

  • You adeed this CSS which only adds space to the left, so it’s uneven.

    .inside-right-sidebar {
        padding-left: 20px;

    Try adding this as well for mobile:

    @media(max-width: 768px) { 
    .inside-right-sidebar {
        padding-right: 20px;
  • I added the code, but the issue is still there. There must be something else that adds extra width to the right side. Maybe the adds. After I converted them into hooks and managed them only as hook codes, I had alignment issues.

  • If the hook is temporarily disabled, does the spacing layout display correctly?

  • will try, I have many hooks, for all the ads on all different places

  • Mobile Homepage is still somehow aligned on the left (the only place where ads are not hooks but inserted as elements). I hide them but still there is a problem.

    Other pages are now ok, after hooks disabled.

    Place take a look at my homepage in mobile view.

  • Private info edited

  • A question. From an optimization perspective, is it better to manage Adsense ads as hooks (pure code and placements) or create them as elements and then hook them in various places?

    If I create elements and put them in containers, I have more control over how they appear in various places without adding extra CSS codes. But if this means more burden and style requests, I guess it is better to only hooks.

    What happens now on a single post on Mobile (now that hooks are disabled)? At first, it is presented well, then the ad appears for a second, then disappears, and the layout is distorted.

    These lines of code were added only because of those Ad Hooks. And it is not working well-

    If you don’t mind, can you go into the admin (private info) and see the best solution?

  • Hi there,

    the alignment issues on the home page, there are 2 main problems:

    1. a container block has a Sizing > Width of 400px which is causing overflow on smaller screens.
    See here:

    Set the Sizing > Max Width to 100% to stop it from overflowing

    2. the lack of padding, in the Customizer > Layout > Container -> Mobile preview. There is NO Left and Right Padding, so the content sticks to the edge of the browser.

    Regarding Elements vs a PHP Snippet for hooking in adverts. The performance difference between the two, if any would be unnoticeable

  • Thank you. I am on it. Which of these two would you recommend?

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