Menampilkan daftar artikel WordPress dengan Svelte Kit Via WordPress Rest Api
2 mins read

Menampilkan daftar artikel WordPress dengan Svelte Kit Via WordPress Rest Api

mrfdn.com – Seperti diketahui, WordPress memiliki fitur bernama Rest API.

Jika fitur ini diaktifkan maka kita dapat menggunakannya secara gratis. Kita bisa menangkap daftar artikel di situs WordPress.

Salah satu cara menggunakan WordPress Rest API adalah dengan Svelte/SvelteKit

SvelteKit memiliki fitur untuk menampilkan data/memuat data dari tautan api. Jadi tanpa basa-basi lagi, ini dia.

  1. Pastikan situs WordPress yang Anda gunakan ada di situsnya dan API-nya aktif. Anda dapat memeriksa halaman tersebut dengan mengetikkan ini di akhir file.
contoh*.com/wp-json/wp/v2/posts

Jika sudah dapat diakses, lanjutkan ke langkah berikutnya.

  1. Tetapkan rencana yang ramping.
npm create svelte@latest my-app
cd my-app
npm install
npm run dev
  1. Pengeditan berkas src/routes/+page.svelte seperti ini:
<script>
  import { onMount } from "svelte";
  let posts = [];
  onMount(async () => {
    const res = await fetch("https://contoh*.com/wp-json/wp/v2/posts");
    posts = await res.json();
  });
</script>

<main class="container">
  <h1>Fetch API WordPress using SVELTE</h1>

  <p>Here is the list articles:</p>

  {#each posts as post}
    <article>
      <header>
        <h3><a href={post.link}>{post.title.rendered}</a></h3>

        <img src={post.jetpack_featured_media_url} alt={post.title.rendered} />
      </header>

      {@html post.excerpt.rendered}
      <footer>
        <small>Diposting pada : <b>{post.date}</b></small>
      </footer>
    </article>
  {/each}
</main>
  1. Jalankan sveldekit pada kotak
npm run dev -- --open

Sekarang Anda telah berhasil membuat halaman web dengan konten yang berisi daftar artikel dari situs WordPress.

Semoga bermanfaat. Semoga beruntung.

PakarPBN

A Private Blog Network (PBN) is a collection of websites that are controlled by a single individual or organization and used primarily to build backlinks to a “money site” in order to influence its ranking in search engines such as Google. The core idea behind a PBN is based on the importance of backlinks in Google’s ranking algorithm. Since Google views backlinks as signals of authority and trust, some website owners attempt to artificially create these signals through a controlled network of sites.

In a typical PBN setup, the owner acquires expired or aged domains that already have existing authority, backlinks, and history. These domains are rebuilt with new content and hosted separately, often using different IP addresses, hosting providers, themes, and ownership details to make them appear unrelated. Within the content published on these sites, links are strategically placed that point to the main website the owner wants to rank higher. By doing this, the owner attempts to pass link equity (also known as “link juice”) from the PBN sites to the target website.

The purpose of a PBN is to give the impression that the target website is naturally earning links from multiple independent sources. If done effectively, this can temporarily improve keyword rankings, increase organic visibility, and drive more traffic from search results.

Jasa Backlink

Download Anime Batch