Title: ubertam's Replies | WordPress.org

---

# ubertam

  [  ](https://wordpress.org/support/users/ubertam/)

 *   [Profile](https://wordpress.org/support/users/ubertam/)
 *   [Topics Started](https://wordpress.org/support/users/ubertam/topics/)
 *   [Replies Created](https://wordpress.org/support/users/ubertam/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/ubertam/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/ubertam/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/ubertam/engagements/)
 *   [Favorites](https://wordpress.org/support/users/ubertam/favorites/)

 Search replies:

## Forum Replies Created

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

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Ultimate Posts Widget] Sort by meta_value_num](https://wordpress.org/support/topic/sort-by-meta_value_num-2/)
 *  Thread Starter [ubertam](https://wordpress.org/support/users/ubertam/)
 * (@ubertam)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/sort-by-meta_value_num-2/#post-8782931)
 * I ended up using Flexible Posts Widget instead, and making a custom plugin to
   let me change the sort.
 * FPW lets you create a custom template (I called mine PCVA FPW Case Result, then
   added the file pcva_fpw_case_result.php to my child theme at \Jupiter-child\flexible-
   posts-widget\pcva_fpw_case_result.php). That PHP file declares the layout of 
   the result so I can have minimal information, make it link where I want it to,
   etc. Here is that code:
 *     ```
       <?php
       /**
        * Flexible Posts Widget: Default widget template
        * 
        * @since 3.4.0
        *
        * This template was added to overcome some often-requested changes
        * to the old default template (widget.php).
        */
   
       // Block direct requests
       if ( !defined('ABSPATH') )
       	die('-1');
   
       echo $before_widget;
   
       if ( ! empty( $title ) )
       	echo $before_title . $title . $after_title;
   
       if ( $flexible_posts->have_posts() ):
       ?>
       	<ul class="dpe-flexible-posts custom-field-case_result_list_entry pcva_fpw_attyresult">
       	<?php while ( $flexible_posts->have_posts() ) : $flexible_posts->the_post(); global $post; ?>
       		<li id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
       			<a href="<?php echo the_permalink(); ?>">
       				<?php the_field('case_result_list_entry'); ?>
       			</a>
       		</li>
       	<?php endwhile; ?>
       	</ul><!-- .dpe-flexible-posts -->
       <?php	
       endif; // End have_posts()
   
       echo $after_widget;
       ```
   
 * Then, I made the following custom plugin so they would be sorted my way. Note:
   this didn’t make the FPW widget interface give me those options; it just overrode
   whatever setting was there. Here’s that plugin code:
 *     ```
       <?php
       /* Adjust Flexible Posts Widget to order by meta_key */
   
       add_filter( 'dpe_fpw_args', 'pcva_fpw_sortmeta' );
   
       function pcva_fpw_sortmeta($query) {
       	$query['meta_key'] = 'hidden_sort_value';
       	$query['orderby'] = 'meta_value_num';
       	return $query;
   
       }
       ```
   
 * FPW already does custom taxonomies, so it had less to tweak to get this to work.
 * Good luck!
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Flexible Posts Widget] Order by meta_value_num to sort my list by a custom value](https://wordpress.org/support/topic/order-by-meta_value_num-to-sort-my-list-by-a-custom-value/)
 *  Thread Starter [ubertam](https://wordpress.org/support/users/ubertam/)
 * (@ubertam)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/order-by-meta_value_num-to-sort-my-list-by-a-custom-value/#post-8397642)
 * If done correctly, it will override whatever the widget setting is set to. My
   guess is the code I added above isn’t being recognized. Couple possibilities:
 * Is your code properly done in a custom plugin or in your theme’s functions.php
   file?
    If it is a custom plugin, is that plugin enabled? If sorting by text rather
   than numbers, change ‘meta_value_num’ to ‘meta_value’ – that might just be it.
   Make sure you replace ‘hidden_sort_value’ with your proper custom field.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Ultimate Posts Widget] Sort by meta_value_num](https://wordpress.org/support/topic/sort-by-meta_value_num-2/)
 *  Thread Starter [ubertam](https://wordpress.org/support/users/ubertam/)
 * (@ubertam)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/sort-by-meta_value_num-2/#post-8330719)
 * Supporting custom taxonomies would be extremely awesome, as well. I have taxonomies
   for Case Results called “CR Attorneys” and “CR Practice Areas” so I don’t clutter
   up my “Categories” default taxonomy.
 * I’d be willing to donate $100 to make this happen.

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