Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8211241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:21:47+00:00 2026-06-07T10:21:47+00:00

I have 2 websites, and I wish to show some posts from one on

  • 0

I have 2 websites, and I wish to show some posts from one on the other using an RSS feed.

Trouble is, the default seems to be order by publish date, where as I need them ordered by title. I’m using WordPress, which uses SimplePie (which I believe is pretty common?).

Is there a way to reorder these items before I display them? Thanks.

/**
 * $feed = the RSS feed to display (set via CMS option)
 * $num_posts = the number of posts to display from the feed (set via CMS option)
 */
$max_items = 0;
if($feed !== '') :
    $rss = fetch_feed($feed);
    if(!is_wp_error($rss)) :
        $max_items = $rss->get_item_quantity($num_posts);
        $rss_items = $rss->get_items(0, $max_items);
    endif;
endif;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:21:50+00:00Added an answer on June 7, 2026 at 10:21 am

    Okey, so I’ve come up with an answer that seems to work.

    require_once(ABSPATH . WPINC . '/class-feed.php');
    require_once(ABSPATH . WPINC . '/class-simplepie.php');
    
    class SimplePie_Custom_Sort extends SimplePie{
    
        /**
         * @var string How to order the feed
         * @access private
         */
        var $order_feed_by;
    
        /**
         * Sort the items that are to be displayed in an RSS feed
         */
        function sort_items($a, $b){
    
            /** Construct the sort function name */
            $sort_function = 'sort_items_'.$this->order_feed_by;
    
            /** Check if the sort function exists and call it (call 'parent::sort_items' if not) */
            if(method_exists($this, $sort_function)) :
                $this->$sort_function($a, $b);
            else :
                parent::sort_items($a, $b);
            endif;
    
        }
    
        /**
         * Sort function to sort posts in an RSS feed by title
         */
        function sort_items_title($a, $b){
    
            return $b->get_title() <= $a->get_title();
    
        }
    
    }
    
    function fetch_feed_custom($url, $order_by){
    
        $feed = new SimplePie_Custom_Sort();
        $feed->order_feed_by = $order_by;
        $feed->set_feed_url($url);
        $feed->set_cache_class('WP_Feed_Cache');
        $feed->set_file_class('WP_SimplePie_File');
        $feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 43200, $url));
        do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) );
        $feed->init();
        $feed->handle_content_type();
    
        if($feed->error()) :
            return new WP_Error('simplepie-error', $feed->error());
        endif;
    
        return $feed;
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a large number of websites (>50) which we wish to track using
I wish to download information from the website http://revigo.irb.hr/ which have an interactive menu.
How do I grab meta data from other websites and display on mine in
Using Tumblr's JSON API, I have embedded blog posts into another website. However, the
I have been using readLines() to scrape information from a website in an R
I wish to do some settings in IIS7 which could run asp.net 1.1 websites.For
I have a controller which has 3 functions. I wish to show 3 different
I have several large websites that I wish to create a WIX installer for.
I have been using Flex Slider as a slider plugin for my websites. I
I have a website that I wish to load in a UIWebView, but it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.