Morphim
Forum Replies Created
-
Forum: Plugins
In reply to: [WooCommerce] Sort products by last word in title?Back again. I got it working. My code had an error:
// Name your sortby key whatever you'd like; must correspond to the $sortby in the next function case 'location':
I missed the ‘location’ text which needed changing to ‘surname’
Once done, it worked : )
However, this works with standard Woo product list but I’m using Woof filter which doesn’t honour the ‘surname’ sorting.
I’ll contact them to try to find a fix (unless you can suggest anything??)If not, thanks again for all your help.
Forum: Plugins
In reply to: [WooCommerce] Sort products by last word in title?Hello again. Don’t worry about the above. I added everyone’s surname via the ‘surname’ meta field on my spreadsheet which created the ‘surname’ custom field within each product.
However, having done this and reset all of the position / menu order ids to zero (this was how I had been sorting alphabetically) I still can’t get it to work like your screenshots.
Did you input my code exactly into the theme function file then set the sort order to surname and it just worked?
It’s still sorting alphabetically by first word / name. Very frustrating.Any ideas? Thanks in advance (again : )
Forum: Plugins
In reply to: [WooCommerce] Sort products by last word in title?Hello again.
Thanks very much for taking the time to help me on this. I appreciate it : )I set up one product with ‘surname’ custom field but is there a way to add this field automatically to all products rather than having to edit / add to each product?
I understand that I need to input the actual second name into all products but at the moment I have to recreate the ‘surname’ custom field individually in each product.Thank again.
Forum: Plugins
In reply to: [WooCommerce] Sort products by last word in title?Hello.
Thanks very much for this. I’ve tried to implement what you’ve suggested but I can’t get it to work. I’m no coder so have to fly by the seat of my pants : )
This is what I tried:
Created a new custom field via the products page called ‘surname’Then placed this code in my child theme functions:
/** * Adds WooCommerce catalog sorting options using postmeta, such as custom fields * Tutorial: https://www.skyverge.com/blog/sort-woocommerce-products-custom-fields/ **/ function skyverge_add_postmeta_ordering_args( $sort_args ) { $orderby_value = isset( $_GET['orderby'] ) ? wc_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) ); switch( $orderby_value ) { // Name your sortby key whatever you'd like; must correspond to the $sortby in the next function case 'location': $sort_args['orderby'] = 'meta_value'; // Sort by meta_value because we're using alphabetic sorting $sort_args['order'] = 'asc'; $sort_args['meta_key'] = 'surname'; // use the meta key you've set for your custom field, i.e., something like "location" or "_wholesale_price" break; } return $sort_args; } add_filter( 'woocommerce_get_catalog_ordering_args', 'skyverge_add_postmeta_ordering_args' ); // Add these new sorting arguments to the sortby options on the frontend function skyverge_add_new_postmeta_orderby( $sortby ) { // Adjust the text as desired $sortby['surname'] = __( 'Sort by surname', 'woocommerce' ); return $sortby; } add_filter( 'woocommerce_default_catalog_orderby_options', 'skyverge_add_new_postmeta_orderby' ); add_filter( 'woocommerce_catalog_orderby', 'skyverge_add_new_postmeta_orderby' ); /** * This code should be added to functions.php of your theme **/ add_filter('woocommerce_get_catalog_ordering_args', 'am_woocommerce_catalog_orderby'); function am_woocommerce_catalog_orderby( $args ) { $args['meta_key'] = 'surname'; $args['orderby'] = 'meta_value'; $args['order'] = 'asc'; return $args; }
The second part is to try and get this method of sorting to work by default since I’ve removed the ‘sort by’ dropdown on the products page as this is the only sorting I need to display.
Thanks very much in advance if you are able to point me in the right direction.
- This reply was modified 7 years ago by Morphim.
Forum: Themes and Templates
In reply to: [GeneratePress] Remove background colorHey Tom. Thanks very much for the reply.
If I delete the hex number in the background box, #efefef appears. When I refresh the page, this color seems to load momentarily. I’ve managed to screen grab it and inspect the BG color in photoshop and it’s showing as #f1f1f1, which is odd but might be transitional as I have images as BGs on my site.
This isn’t actually too much of a problem but someone else is seeing a box of this color via mobile on some pages. I can’t replicate what they are seeing (I have an iphone 6 – I think she has a 7) but, if I change the bg color to something bright, like green, I can see this flashing into view on mobile if i scroll quickly. This is more of a problem.
Having said all this, it might be something else causing it but, since I have changed the color to green and can then see green, I’ve assumed it’s this.Thanks once again for any help / advise.
Site is here >> wearenoisy.co.uk/sohovoices/
Forum: Plugins
In reply to: [WooCommerce] Sort products by last word in title?Thanks for the reply. I understand all of the built in sorting options but doing it by hand isn’t practical.
At the moment, I’ve done it (rather labouriously) but sorting products by hand, into the alphabetical order I need, on a spreadsheet then using ‘menu order’ which works but needs amending, by hand, whenever new products are added.I’ve found these pieces of code to enable a similar thing with regular WP post titles. Is it possible to amend something like this for woocommerce products?
function posts_orderby_lastname ($orderby_statement)
{
$orderby_statement = “RIGHT(post_title, LOCATE(‘ ‘, REVERSE(post_title)) – 1) ASC”;
return $orderby_statement;
}Forum: Fixing WordPress
In reply to: WP Audio Player – remove ” ” speech marks around titleIf anyone is interested, I solved this by adding a custom template script of the playlist code, via a plugin, with modifications to remove the quotes / speech marks around the playlist item title.
This solution was actually used to be able to add a download link to the audio within a playlist but made it possible to safely remove the “” too.
The method / script I used is here >>
https://wordpress.stackexchange.com/questions/292585/adding-a-download-link-to-native-wordpress-playlist/I hope this might help someone else : )
- This reply was modified 7 years, 1 month ago by Morphim.
Forum: Plugins
In reply to: [WooCommerce] Woocommerce to Facebook – only highest price displayingHi Hannah
This one >> https://woocommerce.com/products/facebook/
Forum: Plugins
In reply to: [WooCommerce] Woocommerce to Facebook – only highest price displayingQuick edit. I think I see what is happening.
On my site the variation dropdown goes from lowest price product to highest. On Facebook, it’s listing them the other way around; highest at the top of the dropdown, which is why I guess it’s only listing the highest price. If they were in the same order as the website, I’m assuming the lower price would display on the grid as this price is derived from the first option in the dropdown?- This reply was modified 7 years, 1 month ago by Morphim.
Forum: Fixing WordPress
In reply to: WP Audio Player – remove ” ” speech marks around titleYes, as mentioned in my initial post, it’s hard coded. The core thread I linked to is based on this hard coding and suggests moving it to css but, as also mentioned above ‘is marked as ‘fixed’ but this was two years ago and is still hard coded.’
Forum: Fixing WordPress
In reply to: WP Audio Player – remove ” ” speech marks around titleThe easiest thing was to create a quick playlist on a live install of WP I have. As mentioned, this is the same for all playlist on everyone’s WP install using the built in [audio]. The “” seems to be the only thing I can’t easily remove with CSS. Pretty much everything else is selectable. The only thing i think I can do with CSS to remove the “” is hide the whole title, which I don’t want to do.
Here is the link:
https://www.hughjan.us/audio-example/Thanks again for your help
Forum: Fixing WordPress
In reply to: WP Audio Player – remove ” ” speech marks around titleHere is a generic image of a wp playlist. They are all the same and all feature the “” either side of the title, like “teenage dreams” on the first line
https://cdn2.wpbeginner.com/wp-content/uploads/2015/05/audio-playlist-wp.png
Forum: Fixing WordPress
In reply to: WP Audio Player – remove ” ” speech marks around titleHi Andrew. Thanks for the reply. I can’t show you the page as it’s a dev site but the code is this (lines 1838 – 1858 in wp-includes/media.php
<script type="text/html" id="tmpl-wp-playlist-item"> <div class="wp-playlist-item"> <a class="wp-playlist-caption" href="{{ data.src }}"> {{ data.index ? ( data.index + '. ' ) : '' }} <# if ( data.caption ) { #> {{ data.caption }} <# } else { #> <span class="wp-playlist-item-title"><?php /* translators: playlist item title */ printf( _x( '“%s”', 'playlist item title' ), '{{{ data.title }}}' ); ?></span> <# if ( data.artists && data.meta.artist ) { #> <span class="wp-playlist-item-artist"> — {{ data.meta.artist }}</span> <# } #> <# } #> </a> <# if ( data.meta.length_formatted ) { #> <div class="wp-playlist-item-length">{{ data.meta.length_formatted }}</div> <# } #> </div> </script>
It’s obviously this part, which I’ve temporarily edited, knowing that an update will erase it back to default:
printf( _x( '“%s”', 'playlist item title' ), '{{{ data.title }}}' );
edited to this:
printf( _x( '%s', 'playlist item title' ), '{{{ data.title }}}' );
Once again, if there is a functions edit I can use to over-ride this or something else, I’d be grateful of any direction. Thanks
Do’h! Don’t worry. The fa-search unicode does seem to work now. It was just showing a little, grey box with the code inside (as it seems to be doing above) but after refresh, it seems to work now.
Thanks all the same : )Me too … four month later and no sign of support from the developer