Random Quote Machine - a better filtering option?

Hello everyone,
Here’s what I did and figured out so far: https://codepen.io/AnSHLaGG/pen/PRxzzb
Using QuotesOnDesign v 4.0 API

Thing is, when I send a GET request to the API, it fetches back posts uncontrollably, of any length. And only then do I filter out the Twitter-friendly options.

So at times, when a post that is too long is fetched, I’d like it to get skipped. My current ‘if’ statement is working - but whenever a longpost appears, it only won’t show up, and it’s as if the ‘Next Quote’ button does nothing (though it does).

I’ve read multiple times through this https://codex.wordpress.org/Class_Reference/WP_Query and there’s a ton of filters to sort posts by date, size per page, amount of comments etc… and not a single one to control their length. I’ve tried using something along the lines of

'meta_query' => array( 
    key => 'content' 
    value => '140' 
    compare => '<='
)

and it won’t work.

Perhaps you could point me to a better option?

for the onload…

$( window ).on( "load", getANewOne );

for the else…

$('#quote').html(post.content);           
          } //good 'else' option? sending another GET request to get a new post below 140 chars doesn't work :( 
          else{
               getANewOne();
          }
        },
    cache: false  
1 Like

Big THANKS!
I’ve only passed in a new GET request before as is, without adding the actual function to it. Now I see why it wouldn’t work.
There’s a lag whenever a quote is switched to a too long one 3-4 times, guess I’ll hide it with CSS animations.
Thank you again!