Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$( '.load-random-post' ).on( 'click', function( e ) {
$.ajax( {
url: themePostData.postsEndpointURL,
data: {
filter: {
'posts_per_page': 1,
'orderby': 'rand'
},
},
dataType: 'json',
type: 'GET',
success: function( data ) {
var postTitle = data[0]['title']['rendered'];
var section = $( '.post' );
section.find( '.entry-title' ).hide().html( postTitle ).fadeIn( 'slow' );
},
cache: false
} );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment