• Resolved addiprimus

    (@addiprimus)


    The page sort using Feedzy widget and shortcode is not correct. Some items at the top are older and it is just very mixed.

    I really just want to understand how this worked in order to implement a better sort function, so I attempted to place the following in my theme’s function file:

    function feedzy_alphabetical_sort( $a, $b ){
        return strcmp( $a->get_title(), $b->get_title() );
    }
     
    function feedzy_items_title_sort( $items, $feedURL ){
        return usort( $items, 'feedzy_alphabetical_sort' );
    }
    add_filter( 'feedzy_feed_items', 'feedzy_items_title_sort', 9, 2 );

    …which seems to always to lead the following error on any page with the shortcode or widget:
    Fatal error: Call to a member function get_permalink() on a non-object in /home/content/43/10470443/html/blog/wp-content/plugins/feedzy-rss-feeds/includes/abstract/feedzy-rss-feeds-admin-abstract.php on line 495.

    Note, I did not touch any file but the function file. When I remove the code, the website returns to normal functionality.

    My server is running PHP version 5.3.24 and MySQL version 5.5.43.

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

    (@addiprimus)

    After some tinkering, I got the error to go away, and figured it out… I think.

    I’m no coder, but here is the code that I am using:

    function feedzy_date_sort( $a, $b ){
         if( ($a->get_date()) == ($b->get_date()) ) {
    	return 0;
         }
         if (is_a($a->get_date(), 'DateTime')) {
    	return ( ($a->get_date()) < ($b->get_date()) ) ? 1 : -1;
          } else {
    	return ( strtotime($a->get_date()) < strtotime($b->get_date()) ) ? 1 : -1;
          }
    }
     
    function feedzy_items_title_sort( $items, $feedURL){ 
        {
            usort( $items, 'feedzy_date_sort' );
        }
        return $items;
    }
    add_filter( 'feedzy_feed_items', 'feedzy_items_title_sort', 10, 2 );

    Feedback is appreciated!

    Plugin Author Themeisle

    (@themeisle)

    Hey @addiprimus

    Can you tell me what is exactly the sorting criteria you would like to use ? By title alph, dates, etc ?

    Thanks !

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Fatal error when attempting to sort by…’ is closed to new replies.