PurabTech is technical blog for Programmer and Coders
Author: Purab
I am Purab from India, Software development is my profession and teaching is my passion.
Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks.
Purab's Github Repo
Youtube Chanel Video Tutorials
Connect to on LinkedIn
There are many wordpress plugins which using the shortcode. But you easily create custom shortcode for wordpress site. there is no need of external plugin.
custom shortcode for wordpress
Since Version 2.5 WordPress support so called Shortcodes. They have been introduced for creating macros to be use in a posts content. Many people looking for how to create the shortcode in wordpress using theme. It is very easy to build shortcode in wordpress. I given very simple code sample for creating the custom shortcode.
For more information visit following page.
For creating the custom shortcodes you need add following method in functions.php file which is located in your theme folder.
function myshortcode(){
return '<img src="http://images.purabtech.in/How-to-make-empty-the-wordpress-trash-automatically.png">';
}
add_shortcode('myshortcode', 'myshortcode');
custom shortcode for wordpress
you can change the return text or shortcode name aslo.
Featured images are very important feature of wordpress. Many blogger use the featured images on top. With watching the featured images user got idea about blog post or your article. Some time we miss to upload the featured image.
How to show featured image in wordpress admin panel list
But in post list cannot able to see the featured image in admin panel.
I found very nice wordpress plugin which is helpful to show the featured image in admin panel.
Featured Image Column – Adds a column to the edit screen with the featured image if it exists.
This plugin has no options. It simply adds a column before the title (far left) the show’s the posts featured image if it’s supported and/or exists.
Add a defualt image simply by filtering you own image in. Use featured_image_column_default_image or filter your own CSS by using featured_image_column_css.
Add support for a custom default image
How to show featured image in admin panel list – in post list – for wordpress
function my_custom_featured_image_column_image( $image ) {
if ( !has_post_thumbnail() )
return trailingslashit( get_stylesheet_directory_uri() ) . 'images/featured-image.png';
}
add_filter( 'featured_image_column_default_image', 'my_custom_featured_image_column_image' );
Add your own CSS to change the size of the image.
/**
* @use '.featured-image.column-featured-image img {}'
*/
function my_custom_featured_image_css() {
return trailingslashit( get_stylesheet_directory_uri() ) . 'css/featured-image.css'; //URL to your css
}
add_filter( 'featured_image_column_css', 'my_custom_featured_image_css' );
I found this plugin is really helpful to me. Using this plugin I can easily check the featured image.
Many wordpress developers want to remove the theme editor option from wordpress appearance settings menu. Due to security reason removing theme editor from wordpress admin section is really great idea.
In this tutorial I given simple steps to remove theme editor option from your wordpress admin section.
You just need to copy and paste following code into your functions.php file. That will hide the theme editor menu from settings page.
Using following code you can easily remove editor.
function wpapi_remove_editor_menu() {
remove_action('admin_menu', '_add_themes_utility_last', 101);
}
global $remove_submenu_page, $current_user;
get_currentuserinfo();
if($current_user->user_login == 'admin') { //Specify admin name here
add_action('admin_menu', 'wpapi_remove_editor_menu', 1);
}
Sometimes we create pages and posts which are unwanted. In this article, I given code for make empty wordpress trash automatically. Using code deleted items will automatically delete from trash. Open your wp-config.php file which is in the root directory of wordpress installation.
How to make empty wordpress trash automatically
How to make empty wordpress trash automatically
define('EMPTY_TRASH_DAYS', 7 );
Above code will delete the comments from trash section after every seven days.
Seven days are safe to keep trash. This is simple but good option to keep in your wordpress blog.
As per changes of wordpress 3.5 “Full url path to files” which is media library setting is removed from wrodpress settings. If people want to set easily the upload path or subdomain for uploaded images they are not able set it very easily.
wordpress media settings full url path to files removed
wordpress media settings full url path to files removed
If you want to set the subdomain for images in wordpress 3.5 then use following filter code in your functions.php file.
add_filter( 'pre_option_upload_url_path', 'subdomain_upload_url' );
function subdomain_upload_url()
{
return 'http://subdomain.purabtech.in/uploads';
}
The new version of WordPress 3.5 has changed the media page, removing the two fields to define the location and the sub-field of media. There exists a constant wp-config.php, but it does not include sub-domains. This plug-in is designed for installations virgin WordPress. Once activated, the plugin will add two values in the database, you modify later.
W3 Total Cache plugin is most popular wordpress plugin. I written w3 total cache wordpress plugin review, I personally using this plugin for many years. This plugin is recommended by wordpress itself. W3 Total Cache wordpress plugin is downloaded more then 22 milions times.
w3 total cache wordpress plugin review
Following are some features of W3 Total Cache plugin W3 Total Cache:
w3 total cache wordpress plugin review
Easy Web Performance Optimization (WPO) using caching: browser, page, object, database, minify and content delivery network support.
The only WordPress Performance Optimization (WPO) framework; designed to improve user experience and page speed.
Recommended by web hosts like: Page.ly, Synthesis, DreamHost, MediaTemple, Go Daddy, Host Gator and countless more.
Trusted by countless companies like: AT&T, stevesouders.com, mattcutts.com, mashable.com, smashingmagazine.com, makeuseof.com, yoast.com, kiss925.com, pearsonified.com, lockergnome.com, johnchow.com, ilovetypography.com, webdesignerdepot.com, css-tricks.com and tens of thousands of others.
W3 Total Cache improves the user experience of your site by increasing server performance, reducing the download times and providing transparent content delivery network (CDN) integration.
Benefits:
At least 10x improvement in overall site performance (Grade A in YSlow or significant Google Page Speed improvements) when fully configured
Improved conversion rates and “site performance” which affect your site’s rank on Google.com
One of my client faced issue with Autor drop down which is in Admin section.
Display the authors in dropdown menu using hooks.
While creating the New post there was problem with the Author field. There are hundreds of irrelevant selections (users) and it’s difficult to select the right one.
WordPress is by default showing all the users in author drop down. I don’t want to show the other users in author drop down.
Hook/Filter – In wordpress Admin -Add new Post section -Display the authors in a dropdown menu using wp_dropdown_users One of my client faced issue with Autor drop down which is in Admin section. Display the authors in a dropdown menu using hooks
I searched for wp_dropdown_users hook or filter. But I did not found any proper solution.
Following articles are found helpful to me.
http://wordpress.org/support/topic/filter-for-post-quick-edit-author-drop-down
http://codex.wordpress.org/Function_Reference/wp_dropdown_users
Using that code I modified the code and I am able to fix the issue. You can put following code in to functions.php file.
/*
* Hook for showing Admin and Author in Add new Post - Admin section dropdown menu
*/
function wpapi_override_wp_dropdown_users($output) {
global $post, $user_ID;
//get the Admin-role users IDs
$admins = getUsersWithRole('admin');
//get the author-role users IDs
$authors = getUsersWithRole('author');
//merge the array
$result = array_merge($admins, $authors);
//array converted into comma seprated string
$authorsall = implode(",", $result);
// return if this isn't the theme author override dropdown
if (!preg_match('/post_author_override/', $output))
return $output;
// return if we've already replaced the list (end recursion)
if (preg_match('/post_author_override_replaced/', $output))
return $output;
// replacement call to wp_dropdown_users
$output = wp_dropdown_users(array(
'echo' => 0,
'name' => 'post_author_override_replaced',
'selected' => empty($post->ID) ? $user_ID : $post->post_author,
'include_selected' => true,
'include' => $authorsall
));
// put the original name back
$output = preg_replace('/post_author_override_replaced/', 'post_author_override', $output);
return $output;
}
add_filter('wp_dropdown_users', 'wpapi_override_wp_dropdown_users');
/*
* Find User IDs by Role
*/
function getUsersWithRole($role) {
$wp_user_search = new WP_User_Search($usersearch, $userspage, $role);
return $wp_user_search->get_results();
}
Using above code, you can load multiple role users in author drop down.
WordPress Tips, Using social button will slow down your wordpress site. There are so many social button plugins. Which are so beautiful and nice plugins.
Using social button will slow down your wordpress site
But these plugin can cause wild swings in page load times and page load. Sometimes, facebook is busy and that icon slows down your page, sometimes it is twitter.
Some time admin selected so many social icons to show and it takes time to load because that many apache requests will go to server. I personally tested some blogs and They are facing same page load issue. Commonly wordpress page will load in 5 to 6 seconds without this wordpess plugin. But with these plugin it is taking 50 to 60 seconds to load the page.
It will affect to SEO of your site.
Our Test
We tested the following social icons buttons.
Twitter, Twitter (tweet), Facebook, Facebook (like), Delicious, Google Bookmarks, Google Reader, Google email, Posterous, and StumbleUpon.
All icons are failing some time and that causes page load error with your wordpress site. I tested other plugins also which are not for social sharing purpose but there were no issue with worpdress page loading.
commonly these type of plugin will load into your post, page and excerpt. If you open home page or archive page. you will face the slowness.
I am not saying not to use the social share or social button plugin in your wordpress site. But you need to think about wordpress plugins which is causing issue to your site.
Using social button will slow down your wordpress site
I recommond following wordpress plugins which are really nice.
Normally social sharing codes provided by facebook, twitter, etc renders iframes at run-time. These iframes increases page-size and slow-down your website (on client-side).
Social buttons attract more visitors to your site. When users +1, Tweet, or Like your page, it advertises your page to their friends and followers. This plugin adds social buttons to your posts as a small sprite at first and delays loading the real buttons until the user hovers over the social buttons. It delays ~300KB of social button components by loading <6.5KB of our own script and sprite. onMouseOver activates the load of the ~300KB of social button components.
No one likes long load times, but we all want to be able to share our content via Facebook, Twitter, and other social networks. These take a long time to load. Paradox? Not anymore! With WPSocialite (utilizing David Bushell’s amazing SocialiteJS plugin [http://www.socialitejs.com/]) we can manage the loading process of our social sharing links. Load them on hover, on page scroll, and more!
Facebook, Twitter, Google Plus and LinkedIn Share buttons. Super Fast Loading, No Javascript, Only CSS. Responsive Design, Floting Sidebar Option.
The CSS Share Buttons easily allows your blog to be shared. Speedup you site with this share plugin.
Super Fast
This plugin is very light weight. As compared to other Share button plugin This plugin is super fast.
We compared with all famous share button plugin. Our Plugin load CSS from CDN.
It show very lite share button only with HTML and CSS. It does not load any javascript like other We load only one CSS file with this plugin – only 1.5kb css file.
All in One SEO Pack wordpress plugin is most downloaded plugin in wordpress. Our team written, All in One SEO Pack wordpress plugin review which is unique. It downloaded more then 14 milions times.
All in One SEO Pack wordpress plugin review
Search Engine Optimization (SEO) is an important part of any business, but also for professional bloggers and all individuals that are serious enough about how they rank on sites such as Google, Bing or Yahoo.
Here are some features of All in One SEO Pack wordpress plugin:
Some features:
Google Analytics support
Support for Custom Post Types
Advanced Canonical URLs
Fine tune Page Navigational Links
Built-in API so other plugins/themes can access and extend functionality
ONLY plugin to provide SEO Integration for WP e-Commerce sites
Nonce Security
Support for CMS-style WordPress installations
Automatically optimizes your titles for search engines
Generates META tags automatically
Avoids the typical duplicate content found on WordPress blogs
For beginners, you don’t even have to look at the options, it works out-of-the-box. Just install.
For advanced users, you can fine-tune everything
You can override any title and set any META description and any META keywords you want.
Backward-Compatibility with many other plugins, like Auto Meta, Ultimate Tag Warrior and others.
If upgrading, please back up your database first!
All in One SEO Pack wordpress plugin review:
I appreciate free, & never, until now, complain about something that I get for free, but people need to know what they are getting themselves into before they update.
If you want to improve your SEO rating and have order in all your pages and posts.
The most accessible for novice users that never fails. It is feature rich in an unassuming way.
This is a good plug-in with the basic knowledge to improve your blog’s SEO. There are more advanced SEO plug-ins but this one helps users with a basic understanding of SEO. A great plug-in to learn SEO.
All in One SEO is well tested and proven to be the only choice for numbers of Insurance Carriers, Brokers and Agencies nationwide, which sites I built.
Worth mentioning is that All in One SEO is supported by a company, not just one person, so you can rest assure that if help is needed, their support team will be there for you.
wordpress tutorial, wordpress delete old post revisions improve site performance. We given sql commands and suggested some plugin for delete post revisions.
WordPress has auto save functionality. After some time wordpress creates the revision in database tables automatically. It is really useful. If something happens like powercut or browser crashes then you do not loose the your post data.
wordpress delete old post revisions improve site performance
SQL for delete post rivisions.
DELETE wp,wt,wpm FROM wp_posts wp LEFT JOIN wp_term_relationships wt ON (wp.ID = wt.object_id)
LEFT JOIN wp_postmeta wpm ON (wp.ID = wpm.post_id) WHERE wp.post_type = 'revision'
If you want to disable post revision system permanently, you can add following line in wp_config.php file.
define('WP_POST_REVISIONS', false);
But it has some bad issues also. If you have 5 to 10 revision per post and 200 posts then you will have at least 1500 to 2000 entries in table. Most important part is all revisions are unuseful. Each additional revision increase the size of your database thus making the processing time slower and slower.
But do not disable to auto save functionality and revision. you need to clean your db after certain time.
For cleaning the database you can use the following plugins.
This plugin is a ‘One Click’ WordPress Database Cleaner / Optimizer.
Main Features
Deletes redundant revisions of posts and pages (you optionally can keep an ‘x’-amount of the most recent revisions)
Deletes trashed posts, pages and comments (optional)
Deletes spammed comments (optional)
Deletes ‘orphan postmeta items’
Optimizes the database tables (optionally you can exclude certain tables from optimization)
Creates a log file of the optimizations (optional)
Optimization can be scheduled to automatically run once hourly, twice daily, once daily or once weekly at a specific time (optional)
‘Optimize DB (1 click)’ link in the admin bar (optional)
Settings
You can find the settings page in the WP Admin Panel » Settings » Optimize DB Options.
Starting the Optimization
You can start the Optimization in the WP Admin Panel » Tools » Optimize Database. Note: if you use the Scheduler the Optimization will run automatically!
Revision Post is the new features of WordPress ver 2.6 and above. Every time you made a change to your post or page, it will automatic save add a revision, just like a draft. As many as you made change, the more revision you will have in your database. It will not only increase your database size, but also increase your load time as the server need more time to access the database.
Revision Manager is your choice to remove all the revisions quickly to help you to increase the speed of implementation of the SQL statement, and increase the speed of your server load.
wordpress delete old post revisions improve site performance