WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: upPrev Previous Post Animated Notification] Upnext? Link to next post (1 post)

  1. Rockwell_77
    Member
    Posted 3 years ago #

    I am not a coder at all, but I can sometimes stumble my way through code and try to figure out what's going on.

    I love this plugin, but I'm trying to modify this plugin to link to the next newer post (instead of previous).

    I have found an modified the part of the code so that it somewhat functions the way I would like.

    Here is what I have so far:

    $args = array(
                "numberposts" => 1,
                "category" => implode(',',$catIDs),
                "orderby" => "date",
                "order" => "ASC"
            );
            $posts = get_posts($args);
            $i = 0;
            foreach($posts as $row){
                $i++;
                if ($row->ID == get_the_ID())
                    break;
            }
    
            echo "<div id='upprev_box'>\n\t<h6>\n\t\tMore in ";
            the_category(', ');
            echo "<span class='num'> ($i of " . count($posts) . " articles)</span>\n\t</h6>\n\t";
            echo "<div class='upprev_excerpt'>\n\t\t";
            if ($display_thumb)
                echo "<a href='".get_permalink($posts[$i]->ID)."' title='".$posts[$i]->post_title."'>". get_the_post_thumbnail($posts[$i]->ID,array(48,48),array('title'=>$posts[$i]->post_title,'class'=>'upprev_thumb')) . "</a>\n\t\t";
            echo "<p>\n\t\t\t";
            next_post_link('%link','%title', true);

    After making these changes, the next post title and content are displayed, as is desired, but there are still problems as follows:
    - $i of " . count($posts) . " articles does not display the correct post number and total number of posts
    - the very first post (oldest) does not show the upprev callout at all

    Any ideas?

Topic Closed

This topic has been closed to new replies.

About this Topic