• Resolved dapehe

    (@dapehe)


    Hello
    Is it not possible to paginate the series returned by this ordered series function?
    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter dapehe

    (@dapehe)

    Hello
    I have been looking at the plugin code and the only function that gives a list of series ordered by date is get_series_ordered, but you cannot paginate the results with this function. So I have decided to modify it and include it in functions.php. I leave it here, in case it is useful for you.

    /**
     * Get an ordered list of series.
      * 
     * @param args array
     */
    function get_series_ordered_custom($args = '')
    {
        global $wpdb;
        $post_types = apply_filters('orgseries_posttype_support', array('post'));
        $defaults = array('orderby' => 'term_id', 'order' => 'DESC', 'postTypes' => $post_types, 'hide_empty' => TRUE);
        $args = wp_parse_args($args, $defaults);
        extract($args, EXTR_SKIP);
    
        $orderby = strtolower($orderby);
        if ('post_date' == $orderby) {
            if ('ASC' == $order)
                $_orderby = 'min(tp.post_date)';
            else
                $_orderby = 'max(tp.post_date)';
        } else if ('post_modified' == $orderby) {
            if ('ASC' == $order)
                $_orderby = 'min(tp.post_modified)';
            else
                $_orderby = 'max(tp.post_modified)';
        } else if ('name' == $orderby)
            $_orderby = 't.name';
        else if ('slug' == $orderby)
            $_orderby = 't.slug';
        elseif (empty($orderby) || 'id' == $orderby || 'term_id' == $orderby)
            $_orderby = 't.term_id';
        elseif ('count' == $orderby)
            $_orderby = 'tt.count';
        elseif ('rand' == $orderby)
            $_orderby = 'RAND()';
    
        $having = '';
    
        if ($hide_empty) {
            $having = 'HAVING count(tp.id) > 0 ';
        }
    
        $postTypes = "'" . implode("','", $postTypes) . "'";
    
        $query = "SELECT t.term_id, t.name, t.slug, tt.count 
                    FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id 
                    LEFT OUTER JOIN $wpdb->term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id 
                    LEFT OUTER JOIN $wpdb->posts AS tp ON tp.ID = tr.object_id and tp.post_status IN ( 'publish', 'private' ) and tp.post_type in ($postTypes) 
                    WHERE tt.taxonomy = '" . ppseries_get_series_slug() . "' GROUP BY t.term_id, t.name, t.slug $having ORDER BY $_orderby $order LIMIT $number OFFSET $offset";
        $series = $wpdb->get_results($query);
        return $series;
    }
    Plugin Support Riza Maulana Ardiyanto

    (@rizaardiyanto)

    Hi @dapehe

    Thanks for using PublishPress Series.

    We do not have pagination for get_series_ordered() function yet. However, I created a GitHub issue on this one so it can be considered by our developer: https://github.com/publishpress/publishpress-series/issues/868

    Thanks,

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘get_series_ordered() and paginate’ is closed to new replies.