Tuesday, 28 February 2017

AWS Outage Shows Us Why We Need More Cloud Computing Providers

For some of us, February 28th, 2017 will be remembered as the day that felt like half the internet went down to due a major outage from Amazon S3. It felt vaguely familiar to the DNS Doomsday back in October 2016. Even those who don’t use AWS felt the effects as scripts, dependencies, and CDN resources began to timeout across the web, bringing thousands of sites, APIs, and apps to a standstill. This is a very important reminder of why the web needs more cloud computing and providers for storage and delivery. Healthy competition in this space is always a good thing, as it drives costs down for businesses and consumers, and means a wider distribution of services and solutions across multiple providers. AWS Outage
On the morning of February 28th, 2017 services from Amazon S3, part of Amazon Web Services, started to fail. BuiltWith shows that over 600,000 websites currently rely on AWS to power their sites, storage, or services. Amazon Cloud has also been reported to have over 1 million customers. While that might not even seem like that many in the scope of the entire internet, it had a huge ripple effect across the web due to the fact that many services that we all use on a daily
Source: https://managewp.org/articles/14485/aws-outage-shows-us-why-we-need-more-cloud-computing-providers

source https://williechiu40.wordpress.com/2017/03/01/aws-outage-shows-us-why-we-need-more-cloud-computing-providers/

The New Editor and Browser Support

If you have not already, I encourage you to read through the Editor Technical Overview and check out the great work so far in the initial Gutenberg prototype. Progress on the new editor can also be followed on the GitHub project. While the technical overview focuses on what obstacles are faced before forming opinions on the correct way to solve them, it does not focus on the actual technology requirements of the deliverables. As contributors start to create a new and improved editor experience, these technical requirements should be clearly defined and agreed upon so that decisions and progress can be made.
Accessibility, for example, is one technical requirement. All new features must pass WCAG 2.0 AA.
Browser support is another technical requirement. A few lengthy discussions have occurred within #core on Slack and within an issue on Gutenberg’s GitHub. The discussions weigh the pros and cons of dropping support for older browsers in order to use features only supported in newer browsers to improve the editor. It is a tough decision to make because the editing experience will become less useful for a small percentage of users.
This post will attempt to summarize the discussions
Source: https://managewp.org/articles/14484/the-new-editor-and-browser-support

source https://williechiu40.wordpress.com/2017/02/28/the-new-editor-and-browser-support/

Amazon S3 Outage Hits WordPress Businesses, Disrupting Services and Support

Amazon is currently experiencing “high error rates with S3 in US-EAST-1,” causing a massive outage for sites, apps, and services across the web. The AWS service health dashboard was also temporarily affected by the outage. Amazon says it is working at repairing S3 and that they believe they have identified the root cause. @awscloud Care to share the architecture of this status page as an anti-pattern?
— Thorben Heins (@thorbenheins) February 28, 2017
The outage is affecting many popular sites, such as Quora, Netflix, Splitwise, Business Insider, Giphy, Trello, IFTTT, many publishers’ image hosting, filesharing in Slack, and the Docker Registry Hub.
WordPress businesses are also currently affected, especially those that host customer downloads. WooCommerce customers are currently unable to access downloads they purchased. Similarly Envato customers are having difficulty accessing downloads and content.
Yes, we are affected by #AWS #S3 outage too. S3 is having a snag right now…. Quora, Slack, Envato and millions more are suffering…
— WPBakery (@wpbakery) February 28, 2017
We’re aware of issues with functionality of the https://t.co/dGuVluPt9A
Source: https://managewp.org/articles/14483/amazon-s3-outage-hits-wordpress-businesses-disrupting-services-and-support

source https://williechiu40.wordpress.com/2017/02/28/amazon-s3-outage-hits-wordpress-businesses-disrupting-services-and-support/

Data and the WordPress Community

Data is constantly being collected. Whether it’s through your email account, social media, or an online store. Companies are watching how users interact with their websites to improve their digital experience. However, collecting and using data isn’t something the WordPress community does. Vova Feldman, CEO and Founder of Freemius, is working to make data a bigger priority for developers with the company’s newest product, Freemius Insights.
Freemius Insights aims to provide theme developers with data they may not have had access to in the past. See how many active sites are using your theme, how many have deactivated and how many uninstalled. You can even see which version of PHP the user is operating on.
All of this is good to know, but one of the most useful data streams comes when someone uninstalls the product. They will be prompted to choose a reason for uninstalling. This can point to flaws with the theme itself, something you can’t tell from the data on the WordPress dashboard.
According to Feldman, right now a lot of WordPress development is blind. You make your product, put it on the repository, and get some feedback, but not enough. You don’t
Source: https://managewp.org/articles/14482/data-and-the-wordpress-community

source https://williechiu40.wordpress.com/2017/02/28/data-and-the-wordpress-community/

How We Implemented External Featured Images in Nelio Content

Did you know that we’re only three people here at Nelio? And, yet, our posts are pretty cool, huh? That’s because of our new plugin, Nelio Content! Do you want to use it too? At the end of 2009 WordPress 2.9 was released. One of the most interesting features it included was featured images—a new tool themes could enable to improve the look and feel of our blog.
Assuming you’re already using them in your own blog (it’s 2017, so why shouldn’t you?), you’ve probably realized that you may only use images in the media library as featured images. However, if you add a regular image in your posts, you can do so using their URL and, therefore, you can skip the media library. Why so?
Today I’ll explain how featured images work in WordPress, why you can only use images from your media library, and how Nelio Content overcomes this limitation and allows you to set featured images using an external URL.
Featured Images in WordPress
As you can see in WordPress.com:
A featured image represent the contents, mood, or theme of a post or page. Posts and pages can have a single featured image, which many themes and tools can use to enhance the presentation of your site.
Source: https://managewp.org/articles/14481/how-we-implemented-external-featured-images-in-nelio-content

source https://williechiu40.wordpress.com/2017/02/28/how-we-implemented-external-featured-images-in-nelio-content/

Get Wisdom – data capture for plugin developers

One day, I found myself staring at my plugin’s page in the WordPress directory, wondering why there was such a difference between the number of downloads recorded and the number of active installations. I looked around and it appeared to be the same story for every plugin. The information on the Statistics tab seemed so limited and gave me no real clue as to what was going on. So I decided to create a tool to help. Wisdom is, I think, the first WordPress plugin that allows plugin developers to gather and analyse meaningful data on how their plugins are being used. If you’re a plugin developer, you embed some Wisdom code into your plugin which will then transmit data back to your website. Your website collects all the data and presents it to you through filterable charts.
How do you currently measure how your plugins are used?
Let’s say that you are a plugin author. Perhaps you have a few plugins on the WordPress.org repository that you have released to the community after you developed them for some client work. Alternatively, you might sell plugins as a sideline or main business, either through a freemium model, via marketplaces like Code Canyon, or via your own site.
Source: https://managewp.org/articles/14478/get-wisdom-data-capture-for-plugin-developers

source https://williechiu40.wordpress.com/2017/02/28/get-wisdom-data-capture-for-plugin-developers/

Freemius Insights for WordPress Themes – Officially Released!

Today, we’re officially announcing the release of our insights and analytics solution for WordPress theme authors: Freemius Insights for themes – yeah baby! In case you have never heard of the Freemius Insights solution before – it’s an easy-to-use BI tool that provides comprehensive details and metrics about your WordPress product users & usage. Once you integrate it into your product, your users are prompted by an opt-in screen that asks approval to capture their user-data. Then, that data is automatically saved and filtered for you to make use of.
What’s all the excitement about?
Well, up until now, Freemius Insights was only available for WordPress plugin authors, but…
Insert drum roll, please…
Freemius Insights is now officially available for WordPress THEMES, too!
The Freemius team has been hard at work on being able to provide complete analytics and user data for theme authors in the past few months. We have been discussing it with many WordPress theme authors who have expressed an urgent need to use it with their WordPress themes.
Everybody knows that data about WordPress theme users is not something that is easy to come by when
Source: https://managewp.org/articles/14480/freemius-insights-for-wordpress-themes-officially-released

source https://williechiu40.wordpress.com/2017/02/28/freemius-insights-for-wordpress-themes-officially-released/

Announcing WordPress on .NET

After months of implementing the required PHP functionality in Peachpie, our platform is now finally ready to run a larger real-world application: WordPress. Announcing WordPress on .NET
The popular Phalanger project already proved that running a virtually unmodified clone of WordPress on Microsoft .NET is possible. Still the solution had its issues and was not compatible with new WordPress releases. Now the successor to Phalanger, Peachpie, is also able to run WordPress as a fully managed application on .NET and .NET Core.
Please consider this a proof of concept and keep in mind that Peachpie is still a work in progress. We do not recommend using this in a production environment yet. Our primary objective with this announcement is to prove that Peachpie really is compatible with the standard PHP used in WordPress and to demonstrate its benefits.
There are several reasons why it is desirable to run WordPress on .NET:
Performance: compiled code is fast and also optimized by the .NET ‘Jitter’ for your actual system. Additionally, the .NET performance profiler may be used to resolve bottlenecks.
C# Extensibility: plugin functionality can be implemented in a separate
Source: https://managewp.org/articles/14479/announcing-wordpress-on-net

source https://williechiu40.wordpress.com/2017/02/28/announcing-wordpress-on-net/

How will Google’s new ‘Ad’ label impact marketers?

Google started testing a new ‘Ad’ label in January this year, and late last week it was confirmed that this will now be rolled out globally.

This white label with green text and a green outline will replace the green label that was launched in June 2016.

The instant reaction to this is that the new labels fit in quite seamlessly with the rest of the paid placement, perhaps creating less of a contrast between them and their organic counterparts.

So why has Google made the change now, what impact will it have have, and will users even notice the change?

The official line on this update is that Google wants to streamline the number of colors on its results pages, particularly on mobile devices. A Google spokesperson revealed:

“After experimenting with a new search ad label with a green outline, we’ve decided to roll it out. The new ad label is more legible and continues to make our results page easier to read for our users with clear indication of our ad labeling.”

Additionally, they claimed that “the color change had no bearing on consumers’ ability to distinguish ads from organic listings on the page.”

So why make the change at all?

First of all, these changes never occur in a vacuum. This is just an indication of a wider trend and should be viewed in the context of the removal of right-hand side ads, expanded text ads, and the consistent drive towards a ‘mobile-first’ approach.

Add in the growth of ad blockers, intensifying competition in the search industry (with both Facebook and Pinterest upping their efforts), and the constant pressure on Google to grow its revenues, and the reasons for moving to a less noticeable ‘Ad’ label become apparent.

We should also beware the source of this information. Google may say it has had no impact in testing, but that seems a convenient line for a company that is close to obsessive in its desire to attract more paid clicks through attention to the minutiae.

Google is famed – sometimes ridiculed – for this constant tinkering, but it does work.

Their highly-publicized ‘50 shades of blue’ experiment was seen by some as a step too far, but Marissa Meyer made sure to state that it drove an extra $200m in ad revenue. Even at a company of Google’s size, those figures talk.

It is also worth remembering where we have come from with these ‘Ad’ labels. People can have short memories – a fact that such frequent adjustments take advantage of – and this latest change makes sense when viewed at a higher level.

Google’s ‘Ad’ labels have gone from garishly overbearing to their latest camouflage iteration in the course of just two years:

The change from yellow to green in mid-2016 was reported to have a positive impact for paid search CTR, and few will doubt that last week’s move was led by exactly the same motive.

But is this just a myopic attempt to gain clicks (and the accompanying revenue) in the short term? Or is there more at play here?

For many in the organic search industry, this will just be another step in the inexorable march towards paid search domination of results pages.

One assumption at the heart of Google’s latest update is that users simply want to get to the result that answers their query, whether a brand has paid for their click or not. Giving more space to paid placements and a never-ending stream of new products to make these ads more attractive undoubtedly gives prominence to sponsored listings.

But, the counter-argument goes, people prefer organic listings. They know an ad when they see it and will go out of their way to avoid it.


However, one of the reasons this has held sway in the past is that paid search landing pages have at times been of lower quality or of lesser relevance to the query than organic listings. Brands are willing to pay their way to the top, while that right has to be earned in SEO. The quality of the search results in each camp reflected this.

Which brings us to the growing impact of content marketing and user experience signals in SEO. These factors are essential for any successful SEO strategy and they touch all aspects of a brand’s digital footprint – including paid search.

All that effort site owners have put into creating ‘great content’ to improve their SEO rankings plays directly into the hands of AdWords. If Google can convince brands that the best way to get this new content in front of people is to pay for that right, they will do so. The same great content ends up in front of consumers, so everyone wins. Brands still get the traffic (at a higher price), users get the result they want, and Google makes more money.

Someone has to lose, though, and SEO traffic seems most likely to assume this position.

A diminished SEO landscape would be to the detriment of user experience, though, and no monopoly (even one as seemingly immovable as Google) has a divine right to market ownership. Higher CTR for paid listings will have to go hand-in-hand with a better user experience if this pitfall is to be avoided. If the quality of results starts to dip, alternative search engines do exist.

Another argument is that perhaps the role of paid search is starting to change. The AdWords business model is beautifully crafted for a direct response strategy, but it has its limits when it comes to brand marketing. As brand budgets start to move into the digital space, it would make sense to have a less obvious ‘Ad’ label if Google wants to encourage advertisers to spend this budget on AdWords.

As always, there is much room for speculation, even if the central thrust behind this move seems to be an intended increase in paid search revenues.

One thing is for sure, though: we will be keeping a very close eye on CTR for both paid and organic listings over the upcoming days and weeks to see how this plays out.

source https://searchenginewatch.com/2017/02/28/how-will-googles-new-ad-label-impact-marketers/

Episode 25: Bob Dunn & Blogging – How I Built It

In this episode, Bob and I get back to WordPress basics and talk all about blogging! Bob talks about how he built his blog, using plugins (60+!), coming up with good content, and a lot more. This is an excellent episode for anyone who uses WordPress or wants to start a blog. Show Notes
Sponsored by:
Source: https://managewp.org/articles/14477/episode-25-bob-dunn-blogging-how-i-built-it

source https://williechiu40.wordpress.com/2017/02/28/episode-25-bob-dunn-blogging-how-i-built-it/

Responsive Images in WordPress with Cloudinary

If you’re reading this, you’re probably already familiar with responsive images. Even so, it may be helpful to have a little background. (Then we’ll get to the WordPress part, and how to make them even better with Cloudinary.) For most of the Web’s existence, any time you wanted to include an image on a web page, you would create markup that looked like this: <img src="/path/to/my/image.jpg" alt="a very nice image">
In this example, the <img> element references a single image file named `image.jpg` located on a server at `/path/to/my`. This markup is straightforward in that it tells the browser to download and render a specific image file, referenced by the src element, onto the web page.
This arrangement was fine until 2010, when Ethan Marcotte published his seminal article, Responsive Web Design, which popularized the technique of using Cascading Style Sheet media queries to modify the layout of web pages to fit whatever size device a person is using. Responsive web design also increased interest in optimizing the performance of websites based on screen size. This focus made clear just how big a pain point images are for performance, accounting for
Source: https://managewp.org/articles/14476/responsive-images-in-wordpress-with-cloudinary

source https://williechiu40.wordpress.com/2017/02/28/responsive-images-in-wordpress-with-cloudinary/

32 Extremely Useful Tricks for the WordPress Functions File

All WordPress themes come with a powerful functions.php file. This file acts as a plugin and allows you to do lots of cool things on your WordPress site. In this article, we will show you some of the most useful tricks for your WordPress functions file.

Most useful tricks for WordPress functions file

What is Functions File in WordPress?

Functions file commonly known as functions.php file is a WordPress theme file. It comes with all free and premium WordPress themes.

The purpose of this file is to allow theme developers to define theme features and functions. This file acts just like a WordPress plugin and can be used to add your own custom code snippets in WordPress.

You would find many of these code snippets on websites like WPBeginner with instructions telling you to add this code in your theme’s functions.php file or a site-specific WordPress plugin.

Now you may be thinking what’s the difference between a site-specific WordPress plugin and functions.php file? Which one is better?

While functions.php file is more convenient, a site-specific plugin is much better. Simply because it is independent of your WordPress theme and would work regardless of which theme you are using.

On the other hand, a theme’s functions file will only work for that theme and if you switch the theme, then you will have to copy / paste your custom codes into the new theme.

Having said that, here are some extremely useful tricks for the WordPress functions file.

1. Remove WordPress Version Number

You should always use the latest version of WordPress. However, you may still want to remove the WordPress version number from your site. Simply add this code snippet to your functions file.

function wpb_remove_version() {
return '';
add_filter('the_generator', 'wpb_remove_version');

For detailed instructions, see our guide on the right way to remove WordPress version number.

Want to white label your WordPress admin area? Adding a custom dashboard logo is the first step in the process.

First you’ll need to upload your custom logo to your theme’s images folder as custom-logo.png. Make sure your custom logo is 16×16 pixels in size.

After that you can add this code to your theme’s functions file.

function wpb_custom_logo() {
echo '
<style type="text/css">
#wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon:before {
background-image: url(' . get_bloginfo('stylesheet_directory') . '/images/custom-logo.png) !important;
background-position: 0 0;
color:rgba(0, 0, 0, 0);
#wpadminbar #wp-admin-bar-wp-logo.hover > .ab-item .ab-icon {
background-position: 0 0;
//hook into the administrative header output
add_action('wp_before_admin_bar_render', 'wpb_custom_logo');

For alternate methods and more details see our guide on how to add a custom dashboard logo in WordPress.

3. Change the Footer in WordPress Admin Panel

The footer in WordPress admin area shows the message ‘Thank you for creating with WordPress’. You can change it to anything you want by adding this code.

function remove_footer_admin () {

echo 'Fueled by <a href="http://www.wordpress.org" target="_blank">WordPress</a> | WordPress Tutorials: <a href="http://www.wpbeginner.com" target="_blank">WPBeginner</a></p>';


add_filter('admin_footer_text', 'remove_footer_admin');

Feel free to change the text and links that you want to add. Here is how it looks on our test site.

Custom footer in WordPress admin area

4. Add Custom Dashboard Widgets in WordPress

You probably have seen widgets that numerous plugins and themes add in the WordPress dashboard. As a theme developer, you can add one yourself by pasting the following code:

add_action('wp_dashboard_setup', 'my_custom_dashboard_widgets');

function my_custom_dashboard_widgets() {
global $wp_meta_boxes;

wp_add_dashboard_widget('custom_help_widget', 'Theme Support', 'custom_dashboard_help');

function custom_dashboard_help() {
echo '<p>Welcome to Custom Blog Theme! Need help? Contact the developer <a href="mailto:yourusername@gmail.com">here</a>. For WordPress Tutorials visit: <a href="http://www.wpbeginner.com" target="_blank">WPBeginner</a></p>';

This is how it would look like:

Custom dashboard widget in WordPress

For details, see our tutorial on how to add custom dashboard widgets in WordPress.

5. Change the Default Gravatar in WordPress

Have you seen the default mystery man avatar on blogs? You can easily replace it with your own branded custom avatars. Simply upload the image you want to use as default avatar and then add this code to your functions file.

add_filter( 'avatar_defaults', 'wpb_new_gravatar' );
function wpb_new_gravatar ($avatar_defaults) {
$myavatar = 'http://example.com/wp-content/uploads/2017/01/wpb-default-gravatar.png';
$avatar_defaults[$myavatar] = "Default Gravatar";
return $avatar_defaults;

Now you can head over to Settings » Discussion page and select your default avatar.
Custom default gravatar

For detailed instructions, see our guide on how to change the default gravatar in WordPress.

6. Dynamic Copyright Date in WordPress Footer

You can simply add copyright date by editing the footer template in your theme. However, it will not show when your site started and it will not automatically change next year.

You can use this code to add a dynamic copyright date in WordPress footer.

function wpb_copyright() {
global $wpdb;
$copyright_dates = $wpdb->get_results("
YEAR(min(post_date_gmt)) AS firstdate,
YEAR(max(post_date_gmt)) AS lastdate
post_status = 'publish'
$output = '';
if($copyright_dates) {
$copyright = "© " . $copyright_dates[0]->firstdate;
if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) {
$copyright .= '-' . $copyright_dates[0]->lastdate;
$output = $copyright;
return $output;

After adding this function, you’ll need to open your footer.php file and add the following code wherever you like to display the dynamic copyright date:

<?php echo wpb_copyright(); ?>

This function looks for the date of your first post, and the date of your last post. It then echos the years wherever you call the function.

For more details, see our guide on how to add dynamic copyright date in WordPress.

7. Randomly Change Background Color in WordPress

Do you want to randomly change background color on your WordPress upon each visit and page reload? Here is how to easily do this.

First you need to add this code to your theme’s functions file.

function wpb_bg() { 
$rand = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');
$color ='#'.$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].
echo $color;

Next, you’ll need to edit the header.php file in your theme. Locate the <body> tag and add replace it with this line:

<body <?php body_class(); ?> style="background-color:<?php wpb_bg();?>">>

You can now save your changes and visit your website to see this in action.

Random background change in WordPress

For more details and alternate methods, see our tutorial on how to randomly change background color in WordPress.

8. Update WordPress URLs

If your WordPress login page keeps refreshing or you are unable to access admin area, then you need to update WordPress URLs.

One way to do this is by using wp-config.php file. However, if you do that you will not be able to set the correct address on the settings page. The WordPress URL and Site URL fields will be locked and uneditable.

If you want to fix this, then you should add this code to your functions file.

update_option( 'siteurl', 'http://example.com' );
update_option( 'home', 'http://example.com' );

Don’t forget to replace example.com with your own domain name.

Once you are logged in, you can go to Settings and set the URLs there. After that you should remove the code you added to the functions file, otherwise it will keep updating those URLs any time your site is accessed.

9. Add Additional Image Sizes in WordPress

WordPress automatically creates several image sizes when you upload an image. You can also create additional image sizes to use in your theme. Add this code your theme’s functions file.

add_image_size( 'sidebar-thumb', 120, 120, true ); // Hard Crop Mode
add_image_size( 'homepage-thumb', 220, 180 ); // Soft Crop Mode
add_image_size( 'singlepost-thumb', 590, 9999 ); // Unlimited Height Mode

This code creates three new image sizes with different sizes. Feel free to tweak the code to meet your own requirements.

You can display an image size in anywhere in your theme using this code.

<?php the_post_thumbnail( 'homepage-thumb' ); ?>

For detailed instructions, see our guide on how to create additional image sizes in WordPress.

10. Add New Navigation Menus to Your Theme

WordPress allows theme developers to define navigation menus and then display them. Add this code in your theme’s functions file to define a new menu location in your theme.

function wpb_custom_new_menu() {
  register_nav_menu('my-custom-menu',__( 'My Custom Menu' ));
add_action( 'init', 'wpb_custom_new_menu' );

You can now go to Appearance » Menus and you will see ‘My Custom Menu’ as theme location option.

New navigation menu

Now you need to add this code to your theme where you want to display navigation menu.

wp_nav_menu( array( 
    'theme_location' => 'my-custom-menu', 
    'container_class' => 'custom-menu-class' ) ); 

For detailed instructions, see our guide on how to add custom navigation menus in WordPress themes.

11. Add Author Profile Fields

Do you want to add extra fields to your author profiles in WordPress? You can easily do that by adding this code to your functions file:

function wpb_new_contactmethods( $contactmethods ) {
// Add Twitter
$contactmethods['twitter'] = 'Twitter';
//add Facebook
$contactmethods['facebook'] = 'Facebook';

return $contactmethods;

This code will add Twitter and Facebook fields to user profiles in WordPress.

Extra user profile fields in WordPress

You can now display these fields in your author template like this:

<?php echo $curauth->twitter; ?>

You may also want to see our guide on how to add additional user profile fields in WordPress registration.

12. Adding Widget Ready Areas or Sidebar in WordPress Themes

This is one of the most used ones and many developers already know about this. But it deserves to be in this list for those who don’t know. Paste the following code in your functions.php file:

// Register Sidebars
function custom_sidebars() {

        $args = array(
                'id'            => 'custom_sidebar',
                'name'          => __( 'Custom Widget Area', 'text_domain' ),
                'description'   => __( 'A custom widget area', 'text_domain' ),
                'before_title'  => '<h3 class="widget-title">',
                'after_title'   => '</h3>',
                'before_widget' => '<aside id="%1$s" class="widget %2$s">',
                'after_widget'  => '</aside>',
        register_sidebar( $args );

add_action( 'widgets_init', 'custom_sidebars' );

You can now visit Appearance » Widgets page and you will see your new custom widget area.

Newly registered widget area in WordPress

To display this sidebar or widget ready area in your theme add this code:

<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('custom_sidebar') ) : ?>
<!–Default sidebar info goes here–>
<?php endif; ?>

For more details see our guide on how to add dynamic widget ready areas and sidebars in WordPress.

13. Manipulate RSS Feed Footer

Have you seen blogs that adds their advertisement in their RSS Feeds below each post. You can accomplish that easily with a simple function. Paste the following code:

function wpbeginner_postrss($content) {
$content = 'This post was written by Syed Balkhi '.$content.'Check out WPBeginner';
return $content;
add_filter('the_excerpt_rss', 'wpbeginner_postrss');
add_filter('the_content', 'wpbeginner_postrss');

For more information, see our guide on how to add content and completely manipulate your RSS feeds.

14. Add Featured Images to RSS Feeds

The post thumbnail or featured images are usually only displayed within your site design. You can easily extend that functionality to your RSS feed with a simple function in your RSS feed.

function rss_post_thumbnail($content) {
global $post;
if(has_post_thumbnail($post->ID)) {
$content = '<p>' . get_the_post_thumbnail($post->ID) .
'</p>' . get_the_content();
return $content;
add_filter('the_excerpt_rss', 'rss_post_thumbnail');
add_filter('the_content_feed', 'rss_post_thumbnail');

For more details see our guide on how to add post thumbnails to your WordPress RSS feed.

15. Hide Login Errors in WordPress

Login errors in WordPress can be used by hackers to guess whether they entered wrong username or password. By hiding login errors in WordPress you can make your login area a bit more secure.

function no_wordpress_errors(){
  return 'Something is wrong!';
add_filter( 'login_errors', 'no_wordpress_errors' );

Now users see a generic message when they enter incorrect username or password.

No login hints in WordPress

For more information, see our tutorial on how to disable login hints in WordPress login error messages.

16. Disable Login by Email in WordPress

WordPress allows users to login with username or email address. You can easily disable login by email in WordPress by adding this code to your functions file.

remove_filter( 'authenticate', 'wp_authenticate_email_password', 20 );

For more information see our guide on how to disable login by email feature in WordPress.

17. Disable Search Feature in WordPress

If you want to disable search feature on your WordPress site, then simply add this code to your functions file.

function fb_filter_query( $query, $error = true ) {

if ( is_search() ) {
$query->is_search = false;
$query->query_vars[s] = false;
$query->query[s] = false;

// to error
if ( $error == true )
$query->is_404 = true;

add_action( 'parse_query', 'fb_filter_query' );
add_filter( 'get_search_form', create_function( '$a', "return null;" ) );

For more information, see our tutorial on how to disable search feature in WordPress.

18. Delay Posts in RSS Feed

Sometimes you may end up with a grammar or spelling mistake in your article. The mistake goes live and is distributed to your RSS feed subscribers. If you have email subscriptions on your WordPress blog, then those subscribers will get it as well.

Simply add this code in your theme’s functions file.

function publish_later_on_feed($where) {

        global $wpdb;

        if ( is_feed() ) {
                // timestamp in WP-format
                $now = gmdate('Y-m-d H:i:s');

                // value for wait; + device
                $wait = '10'; // integer

                // http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_timestampdiff
                $device = 'MINUTE'; //MINUTE, HOUR, DAY, WEEK, MONTH, YEAR

                // add SQL-sytax to default $where
                $where .= " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$now') > $wait ";
        return $where;

add_filter('posts_where', 'publish_later_on_feed');

In this code we have used 10 minutes as $wait or delay time. Feel free to change that into any number of minutes you want.

For plugin method and more information, see our detailed guide on how to delay posts from appearing in WordPress RSS feed.

19. Change Read More Text for Excerpts in WordPress

Do you want to change the text that appears after the excerpt? Simply add this code to your theme’s functions file.

function modify_read_more_link() {
    return '<a class="more-link" href="' . get_permalink() . '">Your Read More Link Text</a>';
add_filter( 'the_content_more_link', 'modify_read_more_link' );

20. Disable RSS Feeds in WordPress

Not all websites need RSS feeds. If you want to disable RSS feeds on your WordPress site, then add this code to your theme’s functions file.

function fb_disable_feed() {
wp_die( __('No feed available,please visit our <a href="'. get_bloginfo('url') .'">homepage</a>!') );

add_action('do_feed', 'fb_disable_feed', 1);
add_action('do_feed_rdf', 'fb_disable_feed', 1);
add_action('do_feed_rss', 'fb_disable_feed', 1);
add_action('do_feed_rss2', 'fb_disable_feed', 1);
add_action('do_feed_atom', 'fb_disable_feed', 1);

For a plugin method and more information, see our guide on how to disable RSS feeds in WordPress.

21. Change Excerpt Length in WordPress

WordPress limits excerpt lengths to 55 words. If you need to change that, then you can add this code to your functions file.

functionnew_excerpt_length($length) {
return 100;
add_filter('excerpt_length', 'new_excerpt_length');

Change 100 to the number of words you want to show in the excerpts.

For alternate method, you may want to take a look at our guide on how to customize WordPress excerpts (no coding required).

22. Add an Admin User in WordPress

If you have forgotten your WordPress password and email, then you can add an admin user by adding this code to your theme’s functions file using an FTP client.

function wpb_admin_account(){
$user = 'Username';
$pass = 'Password';
$email = 'email@domain.com';
if ( !username_exists( $user )  && !email_exists( $email ) ) {
$user_id = wp_create_user( $user, $pass, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
} }

Don’t forget to fill in the username, password, and email fields. Once you login to your WordPress site, don’t forget to delete the code from your functions file.

For more on this topic, take a look at our tutorial on how to add an admin user in WordPress using FTP.

23. Remove Welcome Panel from WordPress Dashboard

Welcome panel is a meta box added to the dashboard screen of WordPress admin area. It provides useful shortcuts for beginners to do things on their new WordPress site.

Welcome panel in WordPress admin dashboard

You can easily hide by adding this code in your functions file.

remove_action('welcome_panel', 'wp_welcome_panel');

For other methods and more details check out our guide on how to remove welcome panel in WordPress dashboard.

24. Show Total Number of Registered Users in WordPress

Do you want to show total number of registered users on your WordPress site? Simply add this code to your theme’s functions file.

// Function to return user count
function wpb_user_count() { 
$usercount = count_users();
$result = $usercount['total_users']; 
return $result; 
// Creating a shortcode to display user count
add_shortcode('user_count', 'wpb_user_count');

This code creates a shortcode that allows you to display total number of registered users on your site. Now you just need to add this shortcode to [user_count] your post or page where you want to show the total number of users.

For more information and a plugin method, see our tutorial on how to display total number of registered users in WordPress.

25. Exclude Specific Categories from RSS Feed

Do you want to exclude specific categories from your WordPress RSS feed? Add this code to your theme’s functions file.

function exclude_category($query) {
        if ( $query->is_feed ) {
                $query->set('cat', '-5, -2, -3');
return $query;
add_filter('pre_get_posts', 'exclude_category');

26. Enable Shortcode Execution in Text Widgets

By default, WordPress does not execute shortcodes inside text widgets. To fix this you need to simply add this code to your theme’s functions file.

// Enable shortcodes in text widgets

For an alternate method and more information, take a look at our guide on how to use shortcodes in WordPress sidebar widgets.

27. Add Odd and Even CSS Classes to WordPress Posts

You may have seen WordPress themes using an old or even class for WordPress comments. It helps users visualize where one comment ends and the next one begins.

You can use the same technique for your WordPress posts. It looks aesthetically pleasing and helps users quickly scan pages with lots of content. Simply add this code to your theme’s functions file.

function oddeven_post_class ( $classes ) {
   global $current_class;
   $classes[] = $current_class;
   $current_class = ($current_class == 'odd') ? 'even' : 'odd';
   return $classes;
add_filter ( 'post_class' , 'oddeven_post_class' );
global $current_class;
$current_class = 'odd';

This code simply adds an odd or even class to WordPress posts. You can now add custom CSS to style them differently. Here is a sample code to help you get started.

.even {
.odd {

The end result will look something like this:

Alternate colors used for WordPress posts using odd and even CSS classes

Need more detailed instructions? Take a look at our tutorial on how to add odd/even class to your post in WordPress themes.

28. Add Additional File Types to be Uploaded in WordPress

By default, WordPress allows you to upload a limited number of most commonly used file types. However, you can extend it to allow other file types. Add this code to your theme’s functions file:

function my_myme_types($mime_types){
    $mime_types['svg'] = 'image/svg+xml'; //Adding svg extension
    $mime_types['psd'] = 'image/vnd.adobe.photoshop'; //Adding photoshop files
    return $mime_types;
add_filter('upload_mimes', 'my_myme_types', 1, 1);

This code allows you to upload SVG and PSD files to WordPress. You will need to Google to find out the mime types for the file types you want to allow and then use it in the code.

For more on this topic, check out our tutorial on how to add additional file types to be uploaded in WordPress.

By default, when you uplaod an image in WordPress it is automatically linked to the image file or the attachment page. If users click on the image they are then taken to a new page away from your post.

Here is how you can easily stop WordPress from automatically linking image uploads. All you have to do is to add this code snippet to your functions file:

function wpb_imagelink_setup() {
        $image_set = get_option( 'image_default_link_type' );
        if ($image_set !== 'none') {
                update_option('image_default_link_type', 'none');
add_action('admin_init', 'wpb_imagelink_setup', 10);

Now when you upload a new image in WordPress, it will not be automatically linked. You can still link it to the file or attachment page if you want.

Disable default image links in WordPress

You may want to check out our tutorial on how to remove default image links in WordPress for an alternate plugin method and more information.

30. Add an Author Info Box in WordPress Posts

If you run a multi-author site and want to showcase author bios at the end of your post, then you can try this method. Start by adding this code to your functions file:

function wpb_author_info_box( $content ) {

global $post;

// Detect if it is a single post with a post author
if ( is_single() && isset( $post->post_author ) ) {

// Get author's display name 
$display_name = get_the_author_meta( 'display_name', $post->post_author );

// If display name is not available then use nickname as display name
if ( empty( $display_name ) )
$display_name = get_the_author_meta( 'nickname', $post->post_author );

// Get author's biographical information or description
$user_description = get_the_author_meta( 'user_description', $post->post_author );

// Get author's website URL 
$user_website = get_the_author_meta('url', $post->post_author);

// Get link to the author archive page
$user_posts = get_author_posts_url( get_the_author_meta( 'ID' , $post->post_author));
if ( ! empty( $display_name ) )

$author_details = '<p class="author_name">About ' . $display_name . '</p>';

if ( ! empty( $user_description ) )
// Author avatar and bio

$author_details .= '<p class="author_details">' . get_avatar( get_the_author_meta('user_email') , 90 ) . nl2br( $user_description ). '</p>';

$author_details .= '<p class="author_links"><a href="'. $user_posts .'">View all posts by ' . $display_name . '</a>';  

// Check if author has a website in their profile
if ( ! empty( $user_website ) ) {

// Display author website link
$author_details .= ' | <a href="' . $user_website .'" target="_blank" rel="nofollow">Website</a></p>';

} else { 
// if there is no author website then just close the paragraph
$author_details .= '</p>';

// Pass all this info to post content  
$content = $content . '<footer class="author_bio_section" >' . $author_details . '</footer>';
return $content;

// Add our function to the post content filter 
add_action( 'the_content', 'wpb_author_info_box' );

// Allow HTML in author bio section 
remove_filter('pre_user_description', 'wp_filter_kses');

Next you will need to add some custom CSS to make it look better. You can use this sample CSS as an starting point.

background: none repeat scroll 0 0 #F5F5F5;
padding: 15px;
border: 1px solid #ccc;

font-weight: bold;

.author_details img {
border: 1px solid #D8D8D8;
border-radius: 50%;
float: left;
margin: 0 10px 10px 0;

This is how your author box would look like:

Author box

For plugin method and more detailed instructions, check out our article on how to add an author info box in WordPress posts.

31. Disable XML-RPC in WordPress

XML-RPC is a method that allows third party apps to communicate with your WordPress site remotely. This could cause security issues and can be exploited by hackers.

Simply add this code to your functions file to turn off XML-RPC in WordPress:

add_filter('xmlrpc_enabled', '__return_false');

You may want to read our article on how to disable XML-RPC in WordPress for more information.

32. Automatically Link Featured Images to Posts

If your WordPress theme does not automatically link featured images to full articles, then you can try this method. Simply add this code to your theme’s functions file.

function wpb_autolink_featured_images( $html, $post_id, $post_image_id ) {

If (! is_singular()) { 
$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_the_title( $post_id ) ) . '">' . $html . '</a>';
return $html;

} else { 

return $html;


add_filter( 'post_thumbnail_html', 'wpb_autolink_featured_images', 10, 3 );

You may want to read our article on how to automatically link featured images to posts in WordPress.

That’s all for now.

We hope this article helped you learn some new useful tricks for functions.php file in WordPress. You may also want to see our ultimate guide to boost WordPress speed and performance.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post 32 Extremely Useful Tricks for the WordPress Functions File appeared first on WPBeginner.

source http://www.wpbeginner.com/wp-tutorials/25-extremely-useful-tricks-for-the-wordpress-functions-file/

200K sites are using WP Rocket: Here’s what we learned

We created WP Rocket in 2013. A little over 3 years later, we are happy to announce that more than 200,000 WordPress websites are running with WP Rocket on board! Here’s what we learned on our way to speeding up so many websites:
1. You can do good and still make money
When we entered the market, the main WordPress caching solutions were free plugins. Why would people pay for something that’s already free? Well, it turns out that customers aren’t looking for free at all costs. Someone told us recently that we had a knack for finding great solutions to what people need.
The lesson we learned building WP Rocket is that you can do good and still make money. No shame in that. Today, we are at version 2.9.7. of our plugin and keep improving every day. 6 months ago we wrote a blog post to celebrate our 3 year anniversary. In it we were celebrating our 100,000 sites using WP Rocket milestone.
A little more than 6 months later, we doubled the number of websites that have WP Rocket installed. 16,000 WordPress websites install WP Rocket per month.
We’ve achieved these incredible milestones while maintaining our core company values. We still get up every morning with the
Source: https://managewp.org/articles/14475/200k-sites-are-using-wp-rocket-here-s-what-we-learned

source https://williechiu40.wordpress.com/2017/02/28/200k-sites-are-using-wp-rocket-heres-what-we-learned/