Hello all,
Been working on this all day, almost finished, although I feel like I haven’t nearly finished haha.
Got everything working good, gets a quote, prints the quote and the author, button generates new quote, its all working BUT with the quotes on design I have to have the content (quote) as html(), although I would rather use text(). I can make a new URL with the preset quote for twitter because I am using html(), If I use text() I get “< p >” wraps. I know it uses wordpress that wraps it with" “/< p >”"
$(document).ready(function() { //INITIAL FUNCTION OF DOCUMENT
$.ajax({ //INTIAL RANDOM QUOTE
url:
"https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=",
success: function(data) {
var post = data.shift(); // The data is an array of posts. Grab the first one.
$("#auth").text(post.title);
$("#quote").html(post.content);
},
cache: false
});
$("#new-quote").on("click", function() { //ON CLICK
$.ajax({
url:
"https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=",
success: function(data) {
var post = data.shift(); // The data is an array of posts. Grab the first one.
$("#auth").text(post.title);
$("#quote").html(post.content);
},
cache: false
});
});
var b = document.getElementById('tweet'); //or grab it by tagname etc
b.href = "https://twitter.com/intent/tweet?text=copy%20and%20paste%20the%20tweet";
b.target = "_blank";
});
I hope you see what I mean? Can anyone think of a soliution? Something I am missing? At the moment I am just tweeting, please copy and paste the quote!!
Thanks
https://codepen.io/jamiemufu/pen/boKXwK
Here is link to codepen aswell!