How to add multiple custom excerpt length in wordpress

In archive pages, we use the_excerpt() function to show excerpt of each posts. Be default, wordpress uses 55 words as excerpt if you don’t enter anything in Excerpt meta field. Now, if you want to change the length of excerpt, there is a filter available for that. excerpt_length is the filter that you can use to customize the excerpt length, just use it following way: [php] function new_excerpt_length($length) { return 20; } add_filter(‘excerpt_length’, ‘new_excerpt_length’); [/php] You can change 20 to some other integer. But what if you need to use multiple length of excerpt in different archive pages? We, in […]

Continue Reading

You may also like

WordPress: How to load all styles and scripts in footer

We want to load styles and scripts in footer in wordpress to load it faster. In fact the best practice is to load styles in head and the scripts in footer. We can use some minify plugins to minify all styles and/or scripts. But sometimes it creates issues, in most cases in SSL enabled pages minified styles do no work. Also, we don’t have control in third party plugins, some plugins pushes scripts in head and some pushes in footer. So, it’s not possible to go through all plugins and make changes. I have a little code snippet that will […]

Continue Reading

You may also like

How to hide a plugin for non-admin users in wordpress

Today I will show how you can hide a plugin from the users that are non-admin. If you use a multisite, you can control a lots of stuffs with Pro Sites plugin. But what if you don’t want to use Pro Sites? This simple scripts will do the job for you. [php] function custom_plugins( $plugins ){ if ( !is_super_admin() ) { // Add comma separated paths of plugins that you want to hide $hide_plugins = array(‘pluginFolder/pluginFile.php’, ‘pluginFile.php’); foreach ($hide_plugins as $hide_plugin) { unset($plugins[$hide_plugin]); } } return $plugins; } add_filter(‘all_plugins’, ‘custom_plugins’); [/php] You can add those codes in your functions.php in […]

Continue Reading

You may also like

How to redirect user to his primary blog on login in a multisite

Some web admins don’t like to to redirect the user to network site dashboard upon login. So, they want to redirect the user to the primary blog’s dashboard. Well, it’s fair enough. So, if an user 5 subsites, and when he will login, he will be redirected to his primary blog’s dashboard. He will still be able to access all of his sites from My Sites link at the top left of admin bar. He is also able to change his primary blog. So the following script will do the job: [php] function go_to_primary_blog($redirect_to, $request, $user){ $user_info = get_userdata($user->ID); return […]

Continue Reading

You may also like

How to setup a VPS (Ubuntu) for WordPress hosting – A to Z tutorial

VPS is being more popular day by day. Personally I prefer to use DigitalOcean, they are cheap and their support is awesome. They also have tons of tutorial guides, chat community. Also they answer your questions very quickly in their support forum. Let’s dive into the main point. When you will have a VPS droplet, you will get an IP, login username, password that you can use to login in your VPS via command line. There are several tools like Putty in windows, but I love to work in command line in Linux or Mac OS. Let’s assume the IP […]

Continue Reading

You may also like

WordPress Meet The Team Plugin – best ever

Meet the Team is a WordPress plugin that allows you to easily create and manage teams. You can display single teams as multiple columns, you can also showcase all teams as a filterable isotope gallery, easy social links management included. The purpose of this plugin is to allow you to create a “Meet the Team/Partners” page for a website. This plugin makes it easy to create a Team Page to showcase your most important assets. [purchase_link id=”633″ text=”Add to Cart” style=”button” color=”green”] It’s very cheap and easy to use. You can check the “demo” and “how to use” in following […]

Continue Reading

You may also like

How to add login logout link in wordpress menu

We can add login and logout link using Appearance > Menus and then custom link. But then both links will be shown always, doesn’t matter if you are logged in or out. But if you want to use Login link only for visitors and logout link only for members, this little snippet will help you with that. You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name ‘mu-plugins’. If there is no folder […]

Continue Reading

You may also like

WordPress admin user search by name

When we search user from wordpress dashboard (Users > All Users) we can search with username and email address. But we can’t search with first name or last name or both. So, what if we want to use search by name? You can use the following code snippet for that. You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. [php] add_action(‘pre_user_query’,’alter_pre_user_query’); function alter_pre_user_query($user_search) { global $wpdb; $vars = $user_search->query_vars; if (!is_null($vars[‘search’])) { $search = preg_replace(‘/^*/’,”,$vars[‘search’]); $search = preg_replace(‘/*$/’,”,$search); $user_search->query_from .= ” INNER JOIN {$wpdb->usermeta} […]

Continue Reading

You may also like

Change the order of posts in an archive page

WordPress displays posts according to publish date, newer comes first. It happens in all archive pages, even in home page. Did you ever need of changing order of posts in archive page? Or you thought? Well, there is an easy code snippet to shows posts in reverse order. You can add this codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. [php] function change_order($orderby, $query) { global $wpdb; if(is_archive()) $orderby = “{$wpdb->prefix}posts.post_date ASC”; return $orderby; } add_filter(‘posts_orderby’,’change_order’); [/php] Here is_archive() is used to check if the page is […]

Continue Reading

You may also like

WordPress Multisite: How to show popular post acrosee the network (without any plugin)

WordPress Multisite is a very popular platform now a days for owning of a series of blog site. Well, it can be any e-commerce market. You can easily develop a etsy ptsy style market with MarketPress. Also you can charge your store owner for using your platform as well themes and plugins using Pro Sites. It’s fun, huh? Sometimes we need to show popular posts across our site. That can be easily done. But what if you want to grab popular posts across the network in multisite? Well, that’s not also a rocket science. We will see today how to […]

Continue Reading

You may also like