WordPress include plugin in theme

You can include a plugin in a WordPress theme by following these 2 steps:

  1. Unzip your plugin file and place the plugin folder in your theme folder.
  2. Unclude the center file of the plugin in your functions.php by adding:

That’s it! Now your Plugin is included in your WordPress theme.


WordPress disable dashboard for non-admin

By adding this function to your functions.php, non-admin users can’t approach the WordPress admin / dashboard.

// No WordPress admin for non-administrators
add_action('admin_init', 'no_mo_dashboard');
function no_mo_dashboard() {
 if (!current_user_can('manage_options') && $_SERVER['DOING_AJAX'] != '/wp-admin/admin-ajax.php') {
 wp_redirect(home_url()); exit;

I have used this in a project where I created a complete dashboard in the frontend of the website, so where no non-admin user was allowed to visit the WordPress admin / dashboard.


WordPress show admin bar only for Admin

In some situations it is helpful to don’t show the WordPress admin bar to all the user types. By adding the following code to your function.php, the admin bar only shows up when your logged in as Administrator.

// show admin bar only for admins
if (!current_user_can('manage_options')) {
 add_filter('show_admin_bar', '__return_false');

Difference between wp_list_categories and get_categories

The WordPress functions get_categories() and wp_list_categories() are almost the same. They are using almost the same parameters but there is a difference between them:

  • The get_categories() function returns an array of category objects matching the query parameters.
  • The wp_list_categories() displays a list of categories as links.

WordPress developer documention:

get_categories(): http://codex.wordpress.org/Function_Reference/get_categories

wp_list_categories(): http://codex.wordpress.org/Function_Reference/wp_list_categories