Support

Account

Home Forums ACF PRO Sort by slug

Solved

Sort by slug

  • Hello,

    I’m not a developper and I need help with ACF.

    My theme is Neptune, a (very great) theme made with ACF PRO but theme’s author don’t want to help me for what I need : To sort Taxonomy by slug.

    In template taxonomy, Months are sorted by Name field wich it’s very bad : August comes at first, April, etc… I named slugs as 01january, 02february, etc. and I would like this field to be sorted for consistent display.

    As I said, I’m not a developper and the topic “How to order by date field” didn’t helped me at all.

    If I examine element on my web page https://www.cremedechef.com/recette/terrine-de-saumon/ I can see under title TERRINE DE SAUMON that FEATURES (“Caractériques”) comes from “single-recipe-features”. In template “single-recipe-features” show that :

    <?php 
              $this_recipe_features_with_icons = osetin_get_recipe_features_with_icons(get_the_ID());
              $this_recipe_cuisines_with_icons = osetin_get_recipe_cuisines_with_icons(get_the_ID());
              $recipe_cuisine_and_features_html = '';
              if((is_array($this_recipe_features_with_icons) || is_object($this_recipe_features_with_icons)) || (is_array($this_recipe_cuisines_with_icons) || is_object($this_recipe_cuisines_with_icons))){
                $recipe_cuisine_and_features_html.= '<div class="single-recipe-custom-taxonomies position-'.$details_position.'">';
    
                  // FEATURES
                  if (is_array($this_recipe_features_with_icons) || is_object($this_recipe_features_with_icons)){
                    $recipe_cuisine_and_features_html.= '<div class="single-recipe-features"><div class="single-recipe-features-header">'.__('Features:', 'osetin').'</div><ul>';
                    foreach($this_recipe_features_with_icons as $feature){
                      $feature_term = $feature['term'];
                      $recipe_cuisine_and_features_html.= '<li><a href="'.esc_url(get_term_link($feature_term, 'feature')).'"><span class="tooltip-trigger" data-tooltip-header="'.esc_attr($feature_term->name).'"><img src="'.$feature['icon_url'].'" alt="'.esc_attr($feature_term->name).'"/></span></a></li>';
                    }
                    $recipe_cuisine_and_features_html.= '</ul></div>';
                  }

    What code can I integrate there and where ?

  • Are you using the theme itself or is it using a child theme so that you can make changes without the problems of loosing your changes when the theme is updated? If you are not using a child theme then setting up a child theme would be the first step.

    With a child theme in place, more than likely you could add a get_term_args filter to change the sort order used by the theme https://developer.wordpress.org/reference/hooks/get_terms_args/

  • Thank you very much John ! It’s great !
    Yes I’m using a child theme.
    I copied code from your link and puted it in function.php (in child theme). And it works fine without changing anything from the example !
    Best regards

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Sort by slug’ is closed to new replies.