Kode PHP untuk Navigasi Internal Otomatis (Di single.php atau page.php) php

Kode PHP untuk Navigasi Internal Otomatis (Di single.php atau page.php) php

Bro , apakabar semoga selalu dalam keadaan sehat dan walafiat ye .. hee, nah kali ini saya akan share nih , daripada pakai plugin , jika suka oprek website/theme wordpress secara manual , jangan bilang elementor sih ya , saya dapatkan kode ini berkat bantuan di Chatgpt , daripada kebuang saya post saja di website tercinta saya ini yah ,,// \\

 

Guna dari Kode ini adalah mengisi linking antar internal page untuk web yang Kamu pakai dengan WordPress. jadi lebih bagus dari Segi setting Onpagenya , hematnya setting SEO onpage website Kamu akan lebih powerful , untunpage ya.. kalau untuk post banyak ada , bisa memakai “inline post ”

Berikut kodenya :

</span>

<nav class="post-navigation" role="navigation">
<h3 class="nav-heading">Cek Juga Jasa Kami di Antaranya:</h3>
<div class="nav-links">
<?php if (get_previous_post()) : ?>
<div class="nav-previous">
<a href="<?php echo get_permalink(get_previous_post()); ?>" class="nav-button">
← <?php echo get_the_title(get_previous_post()); ?>
</a>
</div>
<?php endif; ?>

<?php if (get_next_post()) : ?>
<div class="nav-next">
<a href="<?php echo get_permalink(get_next_post()); ?>" class="nav-button">
<?php echo get_the_title(get_next_post()); ?> →
</a>
</div>
<?php endif; ?>
</div>
</nav>

<style>
/* Navigasi dengan Heading & Tombol */
.post-navigation {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 40px;
padding: 20px 0;
border-top: 1px solid #ddd;
}

.nav-heading {
font-size: 20px;
font-weight: bold;
margin-bottom: 15px;
text-align: center;
color: #333;
}

.nav-links {
display: flex;
justify-content: space-between;
width: 100%;
max-width: 900px;
gap: 30px;
}

.nav-previous, .nav-next {
flex: 1;
}

.nav-previous {
text-align: left;
}

.nav-next {
text-align: right;
}

.nav-button {
display: inline-block;
padding: 14px 24px;
background-color: #0073aa;
color: white;
text-decoration: none;
font-size: 16px;
font-weight: bold;
border-radius: 8px;
transition: background 0.3s ease, transform 0.2s;
}

.nav-button:hover {
background-color: #005177;
transform: scale(1.05);
}

/* Responsif */
@media (max-width: 600px) {
.nav-links {
flex-direction: column;
text-align: center;
gap: 15px;
}
.nav-previous, .nav-next {
margin-bottom: 10px;
text-align: center;
}
}
</style>

 

oh pasangnya di mana?

Pasangnya di Silakan copy-paste langsung ke single.php atau page.php. 🚀

 

Click to rate this post!
[Total: 1 Average: 5]
See also  Beberapa jenis jasa website yang tersedia di Baliwebnet