Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    I don’t have access to the Essential Grids plugin. However, they possibly have a way to hook into their sorting function to add your own.

    I suggest you contact them with your question and provide them the wiki link above as it shows the meta_query that is needed for sorting.

    Thread Starter paisglobalmedia

    (@paisglobalmedia)

    Okay. I have done. Thank you!

    Thread Starter paisglobalmedia

    (@paisglobalmedia)

    Hi! So, I reached out to essential grids, and they said to use their ‘Meta Data handling’ function to add in my own custom metadata. I have attached a screenshot of what I did, but it seems to not work. When I add it, it apears in the ‘sort by’ menu, but when I use it to sort, the whole grid dies, so I wondered if you’d be able to lend a hand.

    https://www.dropbox.com/s/xkjuujbgoqrylh4/Screen%20Shot%202018-02-09%20at%2010.11.16%20AM.png?dl=0

    Plugin Author Gemini Labs

    (@geminilabs)

    Have you followed step 3 in their instructions? https://www.themepunch.com/essgrid-doc/custom-meta-data/#meta-reference

    Here is another step-by-step set of instructions: https://www.themepunch.com/faq/use-meta-data-theme-another-plugin-grid/

    Here is a video tutorial:

    An finally, here is a solution to a similar question on stackexchange:
    https://wordpress.stackexchange.com/questions/227059/sorting-grids-with-essential-grid-and-events-manger/237806

    If none of these links help you solve the problem, please send me a login to your website and I will take a look.

    • This reply was modified 7 years, 1 month ago by Gemini Labs.
    • This reply was modified 7 years, 1 month ago by Gemini Labs.
    • This reply was modified 7 years, 1 month ago by Gemini Labs.
    Thread Starter paisglobalmedia

    (@paisglobalmedia)

    Hi! Thank you for all of this! I’ve tried all the different options, and I think what the issue is, is that the ID: ‘_glsr_ranking’ isn’t returning anything. The reason I think that is when I put the Metadata into the skin (step 3), it doesn’t show anything.
    How would you like me to send the login details? I can send to an email if that works

    Plugin Author Gemini Labs

    (@geminilabs)

    The “_glsr_ranking” meta_key will only have a value if you have assigned reviews to the posts that you are trying to sort.

    The wiki article handles this by first sorting posts with the meta_key set, and then after displaying the posts that do not have the meta_key value set.

    If you like you can send a login to the site-reviews support email and I will take a look.

    Thread Starter paisglobalmedia

    (@paisglobalmedia)

    Hi! I have sent my login details. Thank you so much!

    Plugin Author Gemini Labs

    (@geminilabs)

    I sent this by email but I’ll put it here too for anyone else having the same problem.

    1. Edit the settings of the grid you want to sort by rating and remove any custom sorting by meta setting.

    2. Once you have done that, add the following code to your theme’s functions.php file. You may add any other grid ID’s that you want to sort by rating inside the array in the functions (i.e. in_array( $grid_id, [14, 23, 221] ) ).

    /**
    ?* Disable caching for the grid shortcode [ess_grid] with an ID of 14
    ?*/
    add_filter( 'essgrid_query_caching', function( $do_cache, $grid_id ) {
    ? ? if( in_array( $grid_id, [14] )) {
    ? ? ? ? return false;
    ? ? }
    ? ? return $do_cache;
    }, 10, 2);
    
    /**
    ?* Customize the WP query for the grid shortcode [ess_grid] with an ID of 14
    ?*/
    add_filter( 'essgrid_get_posts', function( $query, $grid_id ) {
    ? ? if( in_array( $grid_id, [14] )) {
    ? ? ? ? $query['meta_query'] = [
    ? ? ? ? ? ? 'relation' => 'OR',
    ? ? ? ? ? ? ['key' => '_glsr_ranking', 'compare' => 'EXISTS'],
    ? ? ? ? ? ? ['key' => '_glsr_ranking', 'compare' => 'NOT EXISTS'],
    ? ? ? ? ];
    ? ? ? ? $query['order'] = 'DESC';
    ? ? ? ? $query['orderby'] = 'meta_value';
    ? ? }
    ? ? return $query;
    }, 10, 2);
    Plugin Author Gemini Labs

    (@geminilabs)

    Please let me know if this has been resolved.

    Thread Starter paisglobalmedia

    (@paisglobalmedia)

    Yes! I applied it today and it worked perfectly. Thank you so much!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Ordering by star rating’ is closed to new replies.