Search
 
SCRIPT & CODE EXAMPLE
 

PHP

adjacent post sort order by post title

<?php
    $all_posts = new WP_Query(array(
        'orderby' => 'menu_order',
        'order' => 'ASC',
        'posts_per_page' => -1
    ));

    foreach($all_posts->posts as $key => $value) {
        if($value->ID == $post->ID){
            $nextID = $all_posts->posts[$key + 1]->ID;
            $prevID = $all_posts->posts[$key - 1]->ID;
            break;
        }
    }
?>
<?php if($prevID): ?>
    <span class="prev">
        <a href="<?= get_the_permalink($prevID) ?>" rel="prev"><?= get_the_title($prevID) ?></a>
    </span>
<?php endif; ?>
<?php if($nextID): ?>
    <span class="next">
        <a href="<?= get_the_permalink($nextID) ?>" rel="next"><?= get_the_title($nextID) ?></a>
    </span>
<?php endif; ?>
Comment

PREVIOUS NEXT
Code Example
Php :: yii2 activeform adding field css class 
Php :: get last name user 
Php :: php get referrer ajax 
Php :: switch case or case php 
Php :: php md5 password is insecure 
Php :: php artisan preset bootstrap 
Php :: limit wordpress search to title 
Php :: laravel collection flatMap 
Php :: php ref parameter 
Php :: php trait example 
Php :: php pagination ellipsis 
Php :: laravel 7 upload file s3 
Php :: php json decode 
Php :: php multiplei str 
Php :: select statement of table in phpmyadmin 
Php :: php fpdf in phpmailer 
Php :: laravel return a single dimensional array 
Php :: php preplace 
Php :: php 7 The each() function is deprecated. 
Php :: divide page in pdf with page break using php 
Php :: laravel zoom integration 
Php :: laravel display category post by slug 
Php :: group by count mongodb laravel 
Php :: wordpress theme basics including CSS and js 
Php :: PHP If If Else Else Statement 
Php :: create array of zeros php 
Php :: fixing unclosed html tags 
Php :: laravel get next and previous record 
Php :: Export Database Records to CSV 
Php :: php replace url parameter value 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =