Blog

Stories & Insights

Blog

Expert insights, practical tips and the latest Amazon marketplace updates to help your business grow.

Our Latest Blog

Explore strategies and insights for growing your Amazon business.

'; return `
${imageMarkup}
Amazon Insights

${escapeHTML(title)}

${date ? '

' + escapeHTML(date) + '

' : ''} ${summary ? '

' + escapeHTML(summary) + '

' : ''} Read More
`; } async function loadPosts(reset) { if (loading) return; loading = true; loadButton.disabled = true; loadButton.textContent = 'Loading…'; status.textContent = ''; if (reset) { page = 1; grid.innerHTML = ''; } try { const apiURL = new URL('/wp-json/wp/v2/posts', window.location.origin); apiURL.searchParams.set('per_page', '6'); apiURL.searchParams.set('page', String(page)); apiURL.searchParams.set('_embed', '1'); apiURL.searchParams.set('orderby', 'date'); apiURL.searchParams.set('order', 'desc'); const response = await fetch(apiURL.toString(), { headers: { 'Accept': 'application/json' } }); if (!response.ok) { throw new Error('WordPress API returned status ' + response.status); } const posts = await response.json(); totalPages = parseInt(response.headers.get('X-WP-TotalPages') || '1', 10); if (!Array.isArray(posts) || posts.length === 0) { if (page === 1) { status.textContent = 'No published articles could be found.'; } loadButton.hidden = true; } else { grid.insertAdjacentHTML('beforeend', posts.map(renderPost).join('')); page += 1; loadButton.hidden = page > totalPages; } } catch (error) { console.error('AMZ Support Blog:', error); status.textContent = 'Articles could not be loaded. Please refresh the page or check the WordPress posts API.'; loadButton.hidden = true; } finally { loading = false; loadButton.disabled = false; loadButton.textContent = 'Load More Articles'; } } loadButton.addEventListener('click', function () { loadPosts(false); }); loadPosts(true); })();