Welcome to Rise Forums

Join our fantastic community to connect with like-minded website owners, WordPress users, and online entrepreneurs.

Custom Loop Problems

Discussion in 'Design & Development' started by Kris Hoja, Jul 6, 2016.

Thread Status:
Not open for further replies.
  1. #1 Kris Hoja, Jul 6, 2016
    Last edited: Jul 6, 2016
    Hi guys and gals.
    The problem is that I had a custom loop to display stuff, it worked fine until WP version 4.5
    Right now it shows nothing, even error.

    Here is the code http://pastebin.com/J5BCW3gd

    Here are just calls for to get more attention :)
    @Sanjay Ojha @Rhys Wynne @k06mars @Jay Mayu


    EDIT:
    After few changes, I discovered that it's caused by this part of code

    'meta_key' => 'category_order',


    PHP:
                 $cat_order get_field('category_order');
                
    // get all the categories from the database
          
    $cats get_categories(        array (
          
    'meta_key' => 'category_order',
          
    'orderby'   => $cat_order//or 'meta_value_num'
                
    'count',
                
    'posts_per_page' => -1,
                
    'exclude' => '1, 7, 6, 8, 9, 10',
                
    'order' => 'ASC',
                ) );
    But why it works in WP 4.4.4 and not in 4.5 ?
     
  2. Kris Hoja likes this.
  3. Thanks @Sanjay Ojha !
    count is (as far as I remember :) ) something for ACF number field, I wrote that code over a year ago ;)
     
  4. Ahh..ok
    So did you find the real problem ? Also in above post by me, did you read the change log?
    • Since: WordPress 4.5.0 Changed the function signature so that the $args array can be provided as the first parameter. Introduced 'meta_key' and 'meta_value' parameters. Introduced the ability to order results by metadata.
     
    Kris Hoja likes this.
  5. Yeah, I fixed it by changing
    PHP:
    'meta_key' => 'category_order'
    to

    PHP:
    'meta_query' => array(
    'key' =>'category_order',
    ),
    and it works again :)

    Thanks a lot @Sanjay Ojha
     
    Sanjay Ojha likes this.
Thread Status:
Not open for further replies.

Share This Page