Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9201963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:08:42+00:00 2026-06-17T23:08:42+00:00

I have items to display in my wordpress sidebar. Let’s say div1, div2, div3.

  • 0

I have items to display in my wordpress sidebar. Let’s say div1, div2, div3.

My client would like to repeat the sequence of items in the sidebar to fill the height of the sidebar to match the height of the main content area. So, if each div is 200px height and the content in the main div on given page is 1000px, then there should be div1, div2, div3, div1, div2.

I know how to code php and write the loop, but how to know how many loops to run?

Although I think it’s a bit silly, my client is adamant about this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:08:44+00:00Added an answer on June 17, 2026 at 11:08 pm

    I wound up doing this with jQuery. It’s not a floating sidebar, it actually adds img tags as needed to whatever is there already, until no more fit.

    <script type="text/javascript">
    $(function() {
        var contentHeight = $('#content').height();
        var adList = [
            '<img class="ad" src="----url to first ad -----" />', 
            '<img class="ad" src="----url to second ad -----" />', 
            '<img class="ad" src="----url to third ad -----" />', 
            '<img class="ad" src="----url to fourth ad -----" />', 
            '<img class="ad" src="----url to fifth ad -----" />'
            ];
        var adHeight = 285;
        var numRequiredAds = adList.length;
        var heightDiff = contentHeight - (numRequiredAds * adHeight);
        var numAds = Math.floor(heightDiff/adHeight);
        if (heightDiff > adHeight){
            for (var i = 0; i < numAds ; i++) {
                $('#primary').append(adList[i % adList.length]);
            };
        }
    
    });
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have the list items display horizontally and I want to
I have a simple Wordpress theme with a sidebar menu containing main menu items
I have td items that display checkers like so (please forgive its beastly length):
I am running a wordpress if while statement and would like my items to
I have about 700 items to display in the grid view. On a Samsung
I have a page with a list of elements display (items) - which are
currently I have a requirement to display related items in a multi level grid.
I use a QTreeWidget to display multicolumn items, and I want to have a
I have a TreeView that permits the user to select different items. The display
I have a horizontal parent list. Some of the list items display a nested

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.