WordPress.org

Ready to get started?Download WordPress

Forums

upPrev Previous Post Animated Notification
[resolved] I want to display only one category in upprev (3 posts)

  1. wpmhweb
    Member
    Posted 2 years ago #

    Hello everyone!
    I am trying to modify the upPrev Previous Post Animated Notification plugin to only display one category instead of all of them from one post. but I don't know how to do that, I need help. Here is the partial code where I can spot the code to query the categories:

    $catIDs = array();
            foreach((get_the_category()) as $category) {
                $catIDs[] = $category->cat_ID;
            }
            $args = array(
                "numberposts" => -1,
                "category" => implode(',',$catIDs),
                "orderby" => "date",
                "order" => "DESC"
            );

    There is anyway to modify this code to only call one category?
    Thanks for the help!

    http://wordpress.org/extend/plugins/upprev-nytimes-style-next-post-jquery-animated-fly-in-button/

  2. wpmhweb
    Member
    Posted 2 years ago #

    I found the answer, this is what I did:

    $category = get_the_category();
            $args = array(
                "numberposts" => -1,
                "orderby" => "date",
                "order" => "DESC"
            );
            $posts = get_posts($args);
            $i = 0;
            foreach($posts as $row){
                $i++;
                if ($row->ID == get_the_ID())
                    break;
            }

    Then I just echo the result:
    echo $category[0]->cat_name;
    Thanks,

  3. Marcin Pietrzak
    Member
    Posted 2 years ago #

    Try upPrev plugin http://wordpress.org/extend/plugins/upprev/ insted upPrev Previous Post Animated Notification.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic