Evils
Evils

Reputation: 887

How to get the length of a page in Wordpress?

I just started to do some Wordpress Theme Coding.

I would like to integrate a feature in my theme which integrates another element depending on the length of my page entry (content).

The Idea was to say

if( div with content >= 310 px ) {
  <div id="">
  </div>
}

Is there a way to do that?

Thanks for your help!

Upvotes: 0

Views: 211

Answers (1)

jbnunn
jbnunn

Reputation: 6355

If you have jQuery integrated you can just use

$('#div_to_check').height(); 

or for the whole document

$(document).height();

similar to

<script> 
    if( $('#div_to_check').height() >= 310) {    
        document.write('<div id=""></div>');
    }
</script>

Because the content of your page will most likely be variable, you'll need to check the height after the page finishes loading, so I'd definitely do this via Javascript and not attempt it with PHP.

Upvotes: 1

Related Questions