I’ve been trying to get a Members Directory to sort by last name, but have had no luck. Any help would be much appreciated.
The directory is here: http://109.199.101.20/~newfeldenkrais/practitioner-search/results/
The search is powered by the plugin BP Profile Search, but is displaying on the default members page.
Versions:
WP – Version 4.7.5
BP – Version 2.8.2
BP Profile Search – Version 4.7.6
I’ve tried various solutions that I was able to find on Google with no luck, the most recent solution I could find was here: https://buddypress.org/support/topic/custom-searchfilter-based-on-custom-field/
It looks like that solution is looking for the space between the First Name and Last Name to target the last name, but BuddyPress seems to be grabbing the “nicename”, which has no space. So, it isn’t able to target the space for me?
Use this hook in functions.php,
public function alphabetize_by_last_name( $bp_user_query ) {
if ( 'alphabetical' == $bp_user_query->query_vars['type'] )
$bp_user_query->uid_clauses['orderby'] = "ORDER BY substring_index(u.display_name, ' ', -1)";
}
add_action ( 'bp_pre_user_query', 'alphabetize_by_last_name' );
Ref : https://gist.github.com/mgmartel/4463855
https://buddypress.org/support/topic/sort-user-list-by-last-name/
Related
On the WordPress site using Avada, My situation is very much similar to
https://stackoverflow.com/a/40250428/12323081
They have given the code to be added into functions.php, As per my understanding the code should go in the child theme of Avada, but I don't understand where this part of the code will go?
(Which template file should this code be added to?)
Once this is done, you can query for these variables in your template:
if ( get_query_var('firstName') ) {
echo get_query_var('firstName');
}
if ( get_query_var('lastName') ) {
echo get_query_var('lastName');
}
Once added, how can these parameters be called on Front End?
Any help will be highly appreciated.
After doing quite some R&D, there seems to be a very simple solution to get parameters from the URL in WP/Avada.
In order to achieve the result in my question, please use the Title element and then make use of the dynamic field 'Request Parameter' -> Param Type - Get -> Query Var - firstName
The image is attached for reference.
tinyurl.com/yy3vtwxq
I'd like to use the Envato API to download a list of plugins for WordPress available on Code Canyon. However I have been unable to find a way to do so.
For example, I tried to use a get /search/item per their documentation using the parameter category and setting it to "wordpress" however this returned a number of results but nowhere near the 6,040 the site says it has.
The document also mentions the "category code" is what I should be entering as the parameter for "category" but it never defines the category code - unfortunately, this seems common throughout the documentation - there isn't any definition. Another example of this is calling get /catalog/collection. The parameter required is "id" which it describes as "The numeric ID of the collection to return" - but what numeric ID? This one wasn't hard to figure out, if you open a collection the url looks like:
https://codecanyon.net/collections/4945814-about
And the numeric portion is the ID...but I sure could wish for more definitions or examples of what the parameters should look like. :-)
I looked around, but didn't find anything helpful on the web nor does there appear to be a forum hosted by Envato for discussing the API.
Any help is appreciated!
Please find the code which I did to fetch data from envato API :
var themeforest_api="http://marketplace.envato.com/api/v2/new-files:themeforest,wordpress.json";
$.getJSON( themeforest_api, {
format: "json"
}).done(function( data ) {
var html='';
$.each( data['new-files'], function( i, item ) {
html=html+'<li><img src="'+item.thumbnail+'"></li>';
if ( i === 8 ) {
return false;
}
});
$("#all_items").append( html );
});
Hope it will help you for your one too.
In BuddyPress, it shows 20 members per members directory page. I want to list 24 members per page with a pagination and sorting must work perfectly. I tried:
bp_has_members(bp_ajax_querystring('members').'per_page=24'))
It works but pagination and sorting are not working correctly.
For those like me wondering how to do this nowadays and ending here after searching with their fav engine, the proper way is to use a filter in bp-custom.php or the functions.php of your theme.
Cf. https://codex.buddypress.org/developer/using-bp_parse_args-to-filter-buddypress-template-loops/
For the member loop it would be something like :
function my_bp_members_per_page( $retval ) {
$retval['per_page'] = 24;
return $retval;
}
add_filter( 'bp_after_has_members_parse_args', 'my_bp_members_per_page' );
Bonus : this will still work if you use cache like WP Rocket.
Former method doesn't work with cache and logged in user.
You need an '&' for each additional argument.
Try:
bp_has_members(bp_ajax_querystring('members').'&per_page=24'))
To modify this file, you make a copy of it and put it into your child-theme
/your-child-theme/buddypress/members/members-loop.php
Im trying to pull the settings from Woocommerce admin. I found this:
http://oik-plugins.eu/woocommerce-a2z/oik_api/woocommerce_settings_get_option/
$string = woocommerce_settings_get_option( $option_name, $default );
It looks to be a public function but I cannot access from my theme files. It just gives me Fatal error: Call to undefined. Anyone have any idea how you can access the setting from the theme?
I'm trying to get 'woocommerce_frontend_css_primary', $colors['primary'] so can tie them into the rest of the theme. Woocommerce currently just write the values directly to .less file.
Woocommerce docs are a bit misleading, but it turns out there is another function called get_option... as long as you know the name of the option you can use. EG. get array of front end colors:
$woo_styles = get_option( 'woocommerce_frontend_css_colors' );
Im very new to WordPress. I was going through Smooth Slider WP Plugin and saw
if ( function_exists( 'get_smooth_slider_category' ) ) { get_smooth_slider_category('Uncategorized'); }
This pretty much gives what I wanted, but not quite. This pulls all the content in the category and what Im after is just the image URL.
My question is whats "function_exists" in wordpress? and I checked get_smooth_slider_category in functions.php file but couldnt find any. Can someone please explain how function_exists works?
function_exists is a PHP function, not limited to WordPress.
From the manual "Checks the list of defined functions, both built-in (internal) and user-defined, for function_name."
It returns true or false on whether or not the function exists. So you can either create a new function before it that does something slightly different, or prevent an error if it doesn't exist (normally because the required file hasn't been included).
This is a PHP function that checks if the passed in name matches any defined functions (either internal, or user defined).
It is a way to check if a function is "available" before calling it.