Support » Fixing WordPress » How to automatically add random content on blank spaces

  • Hi, I did a search online, but I couldn’t find the answer I was looking for it.
    How do I add something, like text, or any other content, if on single post page a post is short, which leaves blank space below, as my sidebars are at certain lenght. I know how to fill blank spaces manualy, but is there any way it can be done automatically by adding php code or something. let’s say for example have code if post characters are more than 100 display something else. i posted my website’s link where you can see what i mean…

Viewing 7 replies - 1 through 7 (of 7 total)
  • Set a min-height on the style of the post content section that matches your sidebar layout.

    you can check the post’s length for instance with:

    <?php $character_length = strlen(strip_tags(get_the_content())); ?>

    then use that infomation in a conditional statement either in a filter function or after the ‘content’ div in your single.php.

    where is the text suppose to come from?
    any random text?
    related to the post?
    length correlated to the length of the post?

    to Seacoast Web Design:
    Member, that it won’t work, still will have a blank space in post box, but thanks anyway:)

    to alchymyth The Sweeper:
    I haven’t decided what text yet. It could be any random text or related posts excerpt, it’s basicly to fill the blank space where it’s applicable.
    Could you please post an example of the code?
    Let’s say if the post is less than 100 characters or words, then I would like to display extra content to fill the blank space, how it can be done?

    general example for added code after the div with ‘the_content()’:

    <?php if( strlen(strip_tags(get_the_content())) <= 100 ) { ?>
    <span class="filler-text">
    filler text
    <?php } ?>

    Thankyou very much, I will try this 🙂

    it worked. Your help has been very appreciated. 🙂 Thankyou again for it!

    can i use the code above for, if content height is more than, let’s say 600px then display filler text?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to automatically add random content on blank spaces’ is closed to new replies.