Sort users in get_users() in custom order

There is a simpler, faster method than the one by @Warface. This is an extention to @SyHolloway The concept here is to wrap get_users() in a new function in which you can sort the result from get_users() by the include parameter using usort and then return the resulted array sorted by include This function does … Read more

bloginfo(‘stylesheet_directory’) vs. get_stylesheet_directory_uri() and include(‘file.php’) vs. get_template_part()

get_stylesheet_directory_uri() returns a value, it doesn’t print anything. So you have to use: echo get_stylesheet_directory_uri(); get_template_part() is just a wrapper for locate_template(). But the latter has one advantage: It returns the path of the file it has found. Try the following: $path = locate_template( ‘sidebar-front.php’, TRUE ); echo $path;

Problem requiring/including plugin files with plugin_dir_path( __FILE__ )

When using plugin_dir_path() like you do: plugin_dir_path( __FILE__ ); It does return something like: /var/www//wordpress/wp-content/plugins/your-plugin/ So it adds a trailing slash, because as the documentation states: It is a wrapper for trailingslashit( dirname( $file ) );. So remove the slash before the file in your calls: require_once plugin_dir_path( __FILE__ ) . ‘file.php’;

How to prevent wordpress from loading old versions of jquery in wp_head();?

add_action(‘wp_enqueue_scripts’, ‘no_more_jquery’); function no_more_jquery(){ wp_deregister_script(‘jquery’); } That will deregister jquery. But why wouldn’t you want jQuery at all? If you mean to simply use your own, you should do it in that function, like this: add_action(‘wp_enqueue_scripts’, ‘no_more_jquery’); function no_more_jquery(){ wp_deregister_script(‘jquery’); wp_register_script(‘jquery’, “http” . ($_SERVER[‘SERVER_PORT’] == 443 ? “s” : “”) . “://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js”, false, null); wp_enqueue_script(‘jquery’); … Read more

Include files in functions.php

Including a file inside a subdirectory is the same as any other as long as you know the path to the file. Since it’s possible to move the ‘wp-content’ directory, don’t pass that part of the path to the require statement; instead, use the WP_CONTENT_DIR constant. require_once WP_CONTENT_DIR . ‘/new-directory/my-file.php’; Also, you can leave out … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)