Support

Account

Forum Replies Created

  • Interesting topic that helped me sort my /true/false custom fields column.
    It’s all working, but the initial sorting for true / false fields will be asc and we want desc.
    Adding this code under each conditional will fix that :

            $orderdir = $query->get( 'order');
            if('desc' == $orderdir) {
                $query->set('order','asc');
            } else {    
                $query->set('order','desc');
            }
    

    final result :

    		
    if( 'featured' == $orderby ) {
    $query->set('meta_key','featured');
    $query->set('orderby','meta_value');
    $orderdir = $query->get( 'order');
      if('desc' == $orderdir) {
           $query->set('order','asc');
          } else {    
            $query->set('order','desc');
           }
    }
    
  • For those who would like to strip p tags, but keep br tags (or other tags), you can process the output of the field with strip_tags like so :

     $field = get_field('my_wysiwyg_field');
    $formatted_field = strip_tags($field, '<br>');
    echo $formatted_field; ?>

    Simple, yet effective

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