Support

Account

Forum Replies Created

  • No, I dont think so. I have no problem showing the posts I want to show using wp_query.
    What I was is an effective ACF field that lets the customer login, select posts to be displayed and allows them to sort the order of the selected posts.

    Once they have done this, I can get the ids and display them on the front end

  • Had the same query and stumbled on this page.
    I found a solution that works perfectly for anyone else that ends up here.

    1. Create a new ACF Field Group e.g. “Media Metadata”
    2. Add a field as a Link or Page Link or URL (I used Page Link)
    3. Then under Location => Rules “show this field group if” = Attachment
    4. This will add a new link field into each media library item
    (https://www.greengeeks.com/tutorials/article/add-custom-fields-to-media-wordpress/)

    I used a Page Link and added links to my Media in the Media Library.
    So when calling it in my Gallery loop code:

    <?php
    foreach( $images as $image ): 
      
      $link_id = get_post_meta( $image['id'], 'page_link', true); ?>
      
      <a href="<?php the_permalink( $link_id ); ?>" title="<?php echo $image['alt']; ?>">
        <img data-src="<?php echo $image['sizes'][$size]; ?>"/></a>
    
    <?php				  
    endforeach; 
    ?>
  • ACF stores dates as ‘YYYMMDD’ Sorting on this field as either a number or as text should work.

    Even though, as I posted in the original post, I set it as:

    Save Format: dd/mm/yy

    Does it ignore this setting?

    Yes, it does sort by title fine – but I need it to do release date – as I said it is sorting, I know this, but it is not sorting CORRECTLY – it is sorting it alphanumerically instead of chronologically.

    I am at a point where i think i will change the data to Save Format YYYYMMDD so that it will sort alphanumerically and win/win but I wanted to figure out if it is a bug or not.

  • the problem still persists.

    It is just sorting on the first number i.e. all 31st of any month and year and listed first, 30th of any month and year are listed next…

  • Thanks for your response.
    Here is the filter I am using, (I am using it with WooCommerce products) and I am not using type of ‘DATE’ (although I did try when I couldn’t get the following to work)

    	$orderby_value = isset( $_GET['orderby'] ) ? wc_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
    	switch( $orderby_value ) {
    	
    		case 'release_date':
    			$sort_args['orderby']  = 'meta_value';
    			$sort_args['order']    = 'desc';
    			$sort_args['meta_key'] = 'release_date';
    			break;
    		
    	}
    	
    	return $sort_args;
Viewing 6 posts - 1 through 6 (of 6 total)