Support » Plugin: I Order Terms » White Screen of Death

  • Resolved RenegadeMonster

    (@renegademonster)


    I’m looking for a method to sort terms in the order I want, then group posts together under each term. Orderby ID does not work because unfortunately, the terms weren’t added in the order I want to display them in.

    I was hoping this plugin would be the answer for me but I can’t seem to get it to work to test to se if it would be the solution for me.

    Looking at the support thread use with get_the_terms I tried adding the following function:

    function get_the_terms_sort( $terms, $post_id, $taxonomy ) {
    	function cmp_by_custom_order( $a, $b ) {
    		return $a->custom_order - $b->custom_order;
    	}
    	usort( $terms, 'cmp_by_custom_order' );
    
    	return $terms;
    }
    add_filter( 'get_the_terms', 'get_the_terms_sort', 10, 3 );

    Changing the last line to my term ID’s (Is that the correct way to do this?:

    add_filter( 'get_the_terms', 'get_the_terms_sort', 145, 147, 149, 150, 148, 146 );

    The end result of adding this to functions.php is the page where I’m trying to display these posts by terms in that order is just blank white, and no loops run across my entire site now or some times just a blank white page for every page including the admin.

    Running my php plugin in Coda I verified that there are no syntax errors in functions.php, and removing the above code fixes the problem site wide.

    Any idea what I am doing wrong / causing this?

    https://wordpress.org/plugins/i-order-terms/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Igor Jerosimic

    (@x64igor)

    Hi,

    In add_filter( 'get_the_terms', 'get_the_terms_sort', 10, 3 ); number 10 is for filter priority and number 3 is the number of arguments that WP will pass to my function. When you added some weird numbers in their place WP must have gone haywire, so no, that is not the correct way to do it 🙂

    If I’m understanding correctly you need something likes this:

    – category 1
    — post 1
    — post 2
    – category 2
    — post 3
    — post 4

    You can’t do that with my plugin, you would need some custom programming to be able to use sort order from my plugin in this way.

    Thanks for the reply

    I ended up figuring out yesterday that that the filter was not where you put the term ID’s and that I probably couldn’t use your plugin for what I wanted to do.

    I ended up finding a plugin called “WP Term Order” that adds a order column to the table for my Taxonomy tables.

    With this plugin I can either drag the terms to the order I want to in the admin panel or edit each term and place a number in the Order field.

    Then what is nice with that plugin, is I didn’t need any custom code for it to work. All I had to do was change the orderby from ID to order for my loop and bingo, the output of my terms and the posts tagged with them were in the order I wanted.

    ID and Name didn’t give me the proper order that I wanted to display them in.

    Plugin Author Igor Jerosimic

    (@x64igor)

    I’m glad you found plugin that can do what you needed.

    For anyone else looking for the same functionality you can try plugin that @renegademonster mentioned in previous post, my plugin does not sort posts in relation to terms, only terms.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘White Screen of Death’ is closed to new replies.