• I love this plugin. Thank you for making it. It has made my website very data-driven and much, much more automatic than what I usually deal with. I enter one post and now I can have data from that post in multiple places. Our use case is this: we’re a law firm, and we post our case results on the Case Results page, the Attorney’s info page (for the attorneys on that case), and the Practice Area page (for the related practice area). I enter create the case result using a custom post type that integrates Advanced Custom Fields. One of the custom fields is “hidden_value” where I type a numeric value of the case.

    When I try and order by this hidden_value, it sorts alphabetically. 90,000 is above 40,000,000 because 9 comes first (in descending order).

    I’ve made it work by modifying a few things in the plugin manually:

    Changed references to “meta_value” to “meta_value_num” in the main plugin file.
    Changed same reference in wp_options here: s:14:”meta_value_num”

    This works for what I want it to do. But when the plugin gets updated, I have to manually tweak it again.

    Is there any way this can be updated to add another Order By that is “Custom Field (Num)”?

    I would be eternally grateful.

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter ubertam

    (@ubertam)

    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.

    Did you get it to work yet? Same problem here!
    I don’t have the reference in wp_options table?

    Thread Starter ubertam

    (@ubertam)

    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!

    Wow, really thank you a lot for taking the time on this reply! This will defenitely work for me!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Sort by meta_value_num’ is closed to new replies.