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

  • Home
  • SEARCH
  • 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 9038953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:37:02+00:00 2026-06-16T09:37:02+00:00

I have a wordpress site that has a custom sidebar so that we run

  • 0

I have a wordpress site that has a custom sidebar so that we run promotional ads in. The same layout is executed on 10 different pages. to the left of the sidebar is a ‘main content’ area.

The sidebar area pulls from a separate sidebar.php file which has an unordered list of elements (apx. 25) which consist of an image and text each. Onload a shuffle.js function runs in order to show different promos each time.

Here is the script I currently have.

<script type='text/javascript'>//<![CDATA[ 
$(function(){
var li = $('ul li');
var len =li.length;
while($('#shuffleunorderedlist li:visible').length > 28) {
li.eq(parseInt(len * Math.random(), 10)).hide();
}
);//]]>  
</script>

<!--JS shuffle scripts I added at launch-->
<script language="javascript" type="text/javascript"       src="http://orlandovisitornetwork.com/wp-content/themes/Paradise/js/jquery.shuffle.js">       </script>
<script type="text/javascript">jQuery(function($){window.onload = function(){
$('#shufflemultidivcontainer, #shuffleunorderedlist, #shufflemultidivcontainerhotels').shuffle();
};
});
</script>
<!--END shuffle JS Scripts-->​

The problem is the client wants each of the pages columns to be even, pull from the same pool of promo’s and randomly display them. Unfortunately all of the li’s vary in height.

Currently, I have to go in to the code of each page when I add or remove a promo and hide the li’s that would cause the ‘main content’ and ‘sidebar’ to not be of an even height. Of course this doesn’t get them even but very close to it.

To automate this some I am trying to figure out a way to shuffle the promo list, look at the height of ‘main content’ and show as many of the promos from the shuffle so that the ‘sidebar’ is equal to or slightly less than ‘main content’. I have an idea of how to do it but main content not always being the same height and the li’s being different heights is throwing me off.

I looked for WP plugins and something in jQuery that may help me but didn’t find anything.

I hope I made this clear. Appreciate any suggestions and answers. Thanks

You can see the jsfiddle of what I have so far here…. http://jsfiddle.net/2cPMm/

  • 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-16T09:37:03+00:00Added an answer on June 16, 2026 at 9:37 am

    Here’s the code that actually got this working for me. (Of course I got here with the help of everyone on stack.

    jQuery(function($)
    {
        // Shuffle 
    $('ul').shuffle();
    
    // Watch Columns 
    var mainHeight = $('#main').outerHeight();
    var sidebarHeight = $('#sidebar').outerHeight();
    
    // Compare and hide li 
    if (mainHeight < sidebarHeight) { // You are hiding things from the sidebar correct?      Strictly speaking, this check isn't necessary, but it prevents us from looping when we don't   need to. 
     $('div#sidebar li').each(function() {  // I removed reverse as it gave me a reference  error. If it is defined for you, feel free to use it. 
        if (sidebarHeight > mainHeight) {  
            $(this).hide();  // hide only the current element
            sidebarHeight = $("#sidebar").outerHeight(); // update sidebarHeight 
        }
    });
    }
      });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a wordpress site that i've been working on that has some pages
Currently I have a wordpress site on the local development server that has a
I have a wordpress based site, that has data divided in it on the
I have a wordpress site that I only want to allow people to post
I have a WordPress site which have 4 pages with one page is a
I have a wordpress site with 5k post and each post has average 25
I have a site that is going to use Wordpress within the main server
I have been asked to convert an entire site that is currently using wordpress
I have a Wordpress site that I am currently working on and have set
I have a client that has just moved a very larger, well established wordpress

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.