Lorem
IPSUM LOREM

news.unibos.ac.id

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eget porta ipsum. Aenean aliquam lectus auctor, lacinia velit ac, feugiat odio. Nam convallis justo id purus vehicula pulvinar.

11/21/2024

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eget porta ipsum. Aenean aliquam lectus auctor, lacinia velit ac, feugiat odio. Nam convallis justo id purus vehicula pulvinar. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus

jQuery(document).ready(function($) { var siteUrl = 'https://news.unibos.ac.id/'; var restApiEndpoint = siteUrl + 'wp-json/wp/v2/posts'; // Mengambil data menggunakan AJAX $.ajax({ url: restApiEndpoint, type: 'GET', dataType: 'json', success: function(data) { // Memproses dan menampilkan 4 berita terbaru for (var i = 0; i < Math.min(data.length, 1); i++) { (function() { var post = data[i]; // Mendapatkan ID gambar utama dari berita var featuredMediaId = post.featured_media; var postUrl = post.link; // Mengambil data gambar menggunakan endpoint /wp-json/wp/v2/media/{id} $.ajax({ url: siteUrl + 'wp-json/wp/v2/media/' + featuredMediaId, type: 'GET', dataType: 'json', success: function(mediaData) { var imageUrl = mediaData.source_url; // Membuat tampilan HTML untuk setiap berita $("#image-press-release").html(`
`); $("#title-press-release").html(`

${post.title.rendered}

`); $("#excerpt-press-release").html(`

${post.excerpt.rendered}

`); $("#date-press-release").html(` `); }, error: function(error) { console.error('Error fetching media data:', error); } }); })(); } }, error: function(error) { console.error('Error fetching posts data:', error); } }); });