i am trying to make your plugin work as replacement for the wordpress standard search. I use the latest WP version 6.1.1
Your plugin looks good, but I have one irritating problem. For unknown reasons, the selection “ascending/descending” is not working, at least not with dates.
Independent of what I select in “Search Result Order”, the search always shows the oldest entries first, so I guess “ascending”. I am unable to get the newest dates first, as it should be. And yes, i *have* saved the setting and yes, i *have” the correct setting name selected when testing.
I don′t expect this to be a bug in your plugin, this would too obvious. But I have no idea where to look elsewhere, what might cause that problem. Any faint idea?
Thanks!
]]>In addition, on the back-end the list of logos cannot even be filtered to show them by date or alphabetical order. They only show the list by date of creation, like the front-end shortcode.
Not sure what is wrong with the plugin but I noticed other people having the same problem. Any chance this can be fixed? Thank you!
]]>The type of page I want to sort is here: https://www.georgeglazer.com/wpmain/product-category/press-clippings-exhibitions/ As you can see, the titles begin with a year. We want to show the most recent events first, i.e. a title beginning “2020” would be first, followed by titles beginning “2019,” “2018,” etc. In the near future, this page will be broken into subcategories, so it would be good to know how to assign two or more categories to whatever code will accomplish this.
I already have the following custom code in my Child Theme to make default sorting of products in all categories alphabetical, ascending order. I assume something gets added to this code, which works fine:
* * * * *
// DEFAULT PRODUCT SORTING ALPHABETICALLY //
add_filter( ‘woocommerce_get_catalog_ordering_args’, ‘custom_woocommerce_get_catalog_ordering_args’ );
function custom_woocommerce_get_catalog_ordering_args( $args ) {
$orderby_value = isset( $_GET[‘orderby’] ) ? woocommerce_clean( $_GET[‘orderby’] ) : apply_filters( ‘woocommerce_default_catalog_orderby’, get_option( ‘woocommerce_default_catalog_orderby’ ) );
if ( ‘alphabetical’ == $orderby_value || ‘menu_order’ == $orderby_value ) {
$args[‘orderby’] = ‘title’;
$args[‘order’] = ‘ASC’;
}
return $args;
}
add_filter( ‘woocommerce_default_catalog_orderby_options’, ‘custom_woocommerce_catalog_orderby’ );
add_filter( ‘woocommerce_catalog_orderby’, ‘custom_woocommerce_catalog_orderby’ );
function custom_woocommerce_catalog_orderby( $sortby ) {
$sortby[‘alphabetical’] = __( ‘Sort by A to Z’ );
return $sortby;
}
* * * * *
In doing the research on this subject I found this article about ascending vs. descending vs. random order:
https://docs.woocommerce.com/document/custom-sorting-options-ascdesc/
/**
* Add custom sorting options (asc/desc) */
add_filter( ‘woocommerce_get_catalog_ordering_args’, ‘custom_woocommerce_get_catalog_ordering_args’ );
function custom_woocommerce_get_catalog_ordering_args( $args ) {
$orderby_value = isset( $_GET[‘orderby’] ) ? wc_clean( $_GET[‘orderby’] ) : apply_filters( ‘woocommerce_default_catalog_orderby’, get_option( ‘woocommerce_default_catalog_orderby’ ) );
if ( ‘random_list’ == $orderby_value ) {
$args[‘orderby’] = ‘rand’;
$args[‘order’] = ”;
$args[‘meta_key’] = ”;
}
return $args;
}
add_filter( ‘woocommerce_default_catalog_orderby_options’, ‘custom_woocommerce_catalog_orderby’ );
add_filter( ‘woocommerce_catalog_orderby’, ‘custom_woocommerce_catalog_orderby’ );
function custom_woocommerce_catalog_orderby( $sortby ) { $sortby[‘random_list’] = ‘Random’;
return $sortby;
}
* * * * *
And I found this article about changing the default sorting for a specific category, but it’s not exactly what I want to do because it doesn’t address the order, just the type of sorting (by date, by popularity, etc.). Also note that sorting by date means the date that the product was added to the site, not the date in the title:
https://webhostingbuddy.com/blog/woocommerce-default-sort-method-for-specific-category/
//custom function to override default sort by category
function custom_default_catalog_orderby() {
//choose categories where default sorting will be changed
if (is_product_category( array( ‘category1’, ‘category2’, ‘category3’ ))) {
return ‘date’; // sort by latest
}else{
return ‘popularity’; // sort by popularity as the default
} // end if statement
} //end function
add_filter( ‘woocommerce_default_catalog_orderby’, ‘custom_default_catalog_orderby’ ); //add the filter
* * * * *
I should mention that I don’t really understand PHP, although I can use common sense to see what the patterns are. In other words, give me a recipe and I can probably follow it.
–Helen
]]>add_filter( ‘aws_search_results_products’, ‘aws_search_results_products’ );
function aws_search_results_products( $products ) {
usort($products, function ($item1, $item2) {
$a = $item1[‘sku’];
$b = $item2[‘sku’];
if ($a == $b) {
return 0;
}
return ($a < $b) ? 1 : -1;
});
return $products;
}
I want to have the next upcoming event at the top of the list (ASC), not the bottom (DESC).
Here is the relevant code in event-meta-event-single.php
<?php if ( eo_recurs() ) {
//Event recurs - display dates.
$upcoming = new WP_Query(array(
'post_type' => 'event',
'event_start_after' => 'today',
'posts_per_page' => -1,
'event_series' => get_the_ID(),
'group_events_by' => 'occurrence',
));
if ( $upcoming->have_posts() ) : ?>
<br><br><strong><?php _e( 'Upcoming Dates', 'eventorganiser' ); ?>:</strong>
<ul class="eo-upcoming-dates" style="margin-top:10px">
<?php
while ( $upcoming->have_posts() ) {
$upcoming->the_post();
echo '<li>' . eo_format_event_occurrence() . '</li>';
};
?>
</ul>
<?php
wp_reset_postdata();
//With the ID 'eo-upcoming-dates', JS will hide all but the next 5 dates, with options to show more.
wp_enqueue_script( 'eo_front' );
?>
<?php endif; ?>
<?php } ?>
<?php do_action( 'eventorganiser_additional_event_meta' ) ?>
</div>
]]>i used the code which is given in the documentation and putted it in the fuctions.php of my theme. I want to order by event start date (ascending). The most events are ordered correctly but some events arent.
For example the first three events are orderd like this:
1. 01.07.2020
2. 04.05.2020
3. 06.05.2020
Also, all these posts have also been clustered under a category called Articles.
But when I select “Latest Posts” for the homepage settings, the articles display the opposite way, from the last to the first. I’d like to change that order here too.
How can I have the order created with the plugin, also reflected on the home page?
Thanks!
]]>When you first arrive on this page, and you scroll down to the table it filters by name, but I would like it to filter by Total automatically, rather then having to click on total, can this be done?
Cheers.
]]>