Thursday, January 16, 2020

How to Start a WordPress Blog the RIGHT WAY in 7 Easy Steps (2020)

Do you want to start a WordPress blog the right way? We know that starting a blog can be a terrifying thought specially when you are not geeky. Guess what – you are not alone. Having helped over 370,000+ users create a blog, we have decided to create the most comprehensive guide on how to start a WordPress blog without any technical knowledge.

Start a WordPress blog

The process is easy to follow whether you are 20 years old or 60 years old. However if you need help, our expert team will help you setup your blog for free. → Click Here to Get Your Free WordPress Blog Setup! ←

What do you need to start a WordPress blog?

There are three things you need to create a WordPress blog:

  1. A domain name idea (this will be the name of your blog i.e wpbeginner.com)
  2. A web hosting account (this is where your website live on the internet)
  3. Your undivided attention for 30 minutes.

Yes, you read it right. You can start a blog from scratch in less than 30 minutes, and we will walk you through the whole process, step by step.

In this tutorial, we will cover:

  • How to Register a Domain Name for Free
  • How to Choose the Best Web Hosting
  • How to Install and Setup WordPress Blog
  • How to Change Your Blog Design Template
  • How to Write Your First Blog Post
  • How to Customize WordPress Blog with Plugins
  • How to Add a Contact Form
  • How to Setup Google Analytics Tracking
  • How to Optimize Your Website for SEO
  • How to Make Money From Your Blog
  • Resources to Learn and Master WordPress

Ready? Let’s get started.

Video Tutorial

If you don’t like the video or need more instructions, then continue reading.

Step 1. Setup

The biggest mistake beginners make when building a blog is choosing the wrong blogging platform. Thankfully you’re here, so you won’t be making that mistake.

For 95% of users, it makes more sense to use WordPress.org also known as self-hosted WordPress. Why?

Because it is free to use, you can install plugins, customize your blog design, and most importantly make money from your blog without any restrictions (see the difference between WordPress.com vs WordPress.org).

WordPress is also the number one website platform used by all successful blogs. To put in perspective, 34% of all websites on the internet use WordPress!

Now you might be wondering why is WordPress free? What’s the catch?

There’s no catch. It’s free because you have to do the setup and host it yourself.

In other words, you need a domain name and web hosting.

A domain name is what people type to get to your website. It’s your website’s address on the internet. Think google.com or wpbeginner.com

Web hosting is where your website files live. It’s your website’s house on the internet. Every website needs web hosting.

A domain name typically costs around $14.99 / year, and web hosting normally costs $7.99 / month.

That’s a lot of money for beginners who are just starting out.

Thankfully, Bluehost, an official WordPress recommended hosting provider, has agreed to offer our users a free domain name and over 60% off on web hosting.

→ Click here to Claim this Exclusive Bluehost offer ←

Bluehost is one of the oldest web hosting companies on the internet. They are also the largest brand name when it comes to WordPress hosting because they host millions of websites including many of our own.

On top of all this, Bluehost has been working with WordPress since 2005, and they are committed to giving back. That’s why they have promised us that if you cannot get your blog online within 30 minutes by following this tutorial, then our expert team will complete the process for you without any cost. They will compensate us, so you don’t have to. Contact us for free blog setup help.

NOTE: At WPBeginner we believe in transparency. If you sign up with Bluehost using our referral link, we will earn a small commission at no extra cost to you (in fact, you will save money and get a free domain). We would get this commission for recommending just about any WordPress hosting company, but we only recommend products that we use personally use and believe will add value to our readers.

Let’s go ahead and purchase your domain + hosting.

Open up Bluehost in a new window and follow along.

First thing you need to do is click on the green Get Started Now button to get started.

Get started with Bluehost

On the next screen, select the plan that you need (basic and plus are the most popular).

After that, you will be asked to enter the domain name for your website.

Select your domain name

Lastly, you will need to add your account information and finalize the package info to complete the process. We recommend going with the 36-month plan because that’s the best value.

On this screen, you will see optional extras that you can purchase. It’s entirely up to you whether or not you purchase these, but we generally don’t recommend purchasing them right away. You can always add them later on, if you decide that you need them.

Hosting checkout for starting a blog

Once completed, you will receive an email with details on how to login to your web hosting control panel (cPanel). This is where you manage everything from support, emails, among other things. But most importantly, this is where you install WordPress.

Step 2. Install WordPress

When you signup with the new version of Bluehost using our link, they will automatically install WordPress for you. This new version was recently launched to make it easier for non-techy users to create their blog.

What this means is you simply need to login to your Bluehost account, and then click the Login to WordPress button to get started.

Log in to your WordPress blog from Bluehost dashboard

You can also login to WordPress by simply going to yoursite.com/wp-admin/ directly from your browser.

If you are using a different WordPress blog hosting service like SiteGround, HostGator, WP Engine, etc, then you can see our comprehensive guide on how to install WordPress for step by step instructions for those providers.

Once WordPress is setup, you’re ready to customize your blog’s appearance to make it your own and start blogging.

Step 3. Selecting Your WordPress Theme

The visual appearance of your WordPress blog is controlled by themes. When you first visit your blog, it will look something like this:

Default WordPress theme

This is not very appealing to most people.

Customizing the look and feel of your blog is by far one of the most exciting and rewarding part in the journey of creating your WordPress blog.

There are thousands of pre-made WordPress themes that you can install on your site. Some of them are free themes, while others are paid.

You can change your theme by going to your WordPress dashboard and clicking on Appearance » Themes.

Add new WordPress theme

Go ahead and click on the Add New button.

On the next screen, you will able to search from 7,400+ free WordPress themes that are available in the official WordPress.org themes directory. You can sort by popular, latest, featured, as well as other feature filters (i.e industry, layout, etc).

Select a theme

You can take your mouse over to a theme, and you will see a Preview button. Clicking on it will open the theme preview where you can see how the design would look on your website.

Preview theme

The preview of your theme may not look exactly as shown in the screenshot, which is normal as you will get to customize and set it up later. What you need to look for is design, colors, typography, and other elements.

The best tip to select the perfect WordPress theme is to strive for simplicity in design. It helps you keep things clean and clear while offering a good experience to your users.

When you have found the theme that you like, simply bring your mouse on it, and it will show the Install button. Click on it and wait for the theme to be installed. After that, the install button will be replaced with an Activate button. You need to click on it to Activate the theme.

Install and activate the WordPress theme

Once you have installed your theme, you can customize it by clicking on the Customize link under the Appearance menu.

If you need help selecting a theme, then please refer to our guide on 9 things you should consider when selecting a perfect WordPress theme.

Once you have selected your WordPress theme, you are now ready to create your first blog post.

Step 4. Creating Your First Blog Post

To write a blog post, click on the Posts » Add New menu in your WordPress dashboard.

You will see an editor area where you can write your first blog post.

Writing a blog post in WordPress

WordPress uses a block-based editor where each element is a block. This allows you to create beautiful content layouts for your blog posts.

To familiarize yourself with the editor, see our WordPress block editor tutorial.

Once you’re done writing, go ahead and click on the Publish button on the top-right corner of the screen to make your blog post publicly available.

Publish blog post

On the posts screen, you will notice several other sections such as Categories and Tags. You can use these to organize your blog posts into sections. We have a great writeup on the difference between categories vs tags, which we highly recommend that you read.

To utilize all the features on the posts screen, you should read our article on how to add a new post in WordPress (video included).

Often beginners are confused between posts and pages menu in the WordPress dashboard. That’s why we have also written a complete guide on the difference between posts vs pages in WordPress.

Step 5. Plugins & Customizations

Once you have written your first sample blog post, you probably want to get started with adding other usual elements on your website such as contact forms, galleries, sliders, newsletter subscription form, etc.

To add all these additional features, you need to use plugins.

WordPress plugins are apps that allow you to add new features to your website (without writing any code).

There are over 55,000 WordPress plugins available in the free WordPress plugin directory alone. This means no matter what you want to accomplish, there is a plugin for it.

We have a step by step guide on how to install a WordPress plugin.

That being said, let’s take a look at how to use plugins to add some essential features to your WordPress blog.

How to Create a Contact Form in WordPress

Every website needs a contact form. It allows your users to email you directly. Since WordPress doesn’t come with a built-in contact form, you will need a WordPress form builder plugin to add a contact form on your site.

We recommend using the WPForms Lite plugin. It is a free version of the popular WPForms plugin, which is #1 in our list of best contact form plugins for WordPress.

Over 3 million websites use WPForms!

You can install the plugin by going to Plugins » Add New page and typing WPForms in the search box. Next, you need to click “Install” and then “Activate”. Upon activation, you need to head over to WPForms » Add New page to create your first form.

Adding a new contact form in WordPress

This will open the WPForms builder interface.

First, you need to enter a name for your contact form and then click on ‘Simple Contact Form’ template.

Simple contact form

WPForms will now create a simple contact form for you with all the required fields. You can click on any field to change it, or add a new field from the left column.

Editing your contact form

Once you are done editing the form, click on the save button at the top right corner and then exit the form builder.

You can now create a new page in WordPress by going to Pages » Add New and call it ‘Contact’. On the edit screen, you need to enter the WPForms block into the editor.

Add WPForms block to the editor

After that, select the form you created earlier from the drop down menu and WPForms will load a live preview of the form in the editor.

Select your contact form

You can now save and publish the page and visit it in your browser to see your contact form in action.

If you need more detailed instructions, then see our step by step guide on how to create a contact form in WordPress.

How to Setup Google Analytics Tracking

Google Analytics helps you see how many people are visiting your blog, where they are coming from, and what are they doing on your website?

It is best to install Google Analytics when starting your blog, so you can see how much your blog has grown over time.

First, you need to visit Google Analytics website and sign in using your Gmail account.

Once you are logged in, you can go ahead and sign up for a free Google Analytics account.

Google Analytics sign up

You will be asked to provide your information and website URL. After that, you will be presented with your Google Analytics tracking code.

You can stop here because we will be using a plugin to automatically fetch and add this code to your blog (along with setting up proper WordPress tracking).

Switch to your WordPress admin area to install and activate the MonsterInsights plugin. It is the free version of the best Google Analytics plugin for WordPress, and it is the easiest way to add Google Analytics on your site (trusted by over 2 million websites).

Upon activation, you need to visit Insights » Settings page to configure the plugin settings.

Connect Google Analytics using MonsterInsights

On the settings page, click on the ‘Connect MonsterInsights’ button to connect Google Analytics to your WordPress site.

Follow the on-screen instructions to complete the setup. Once done, you will be able to see your website analytics report straight from your WordPress dashboard under the MonsterInsights tab.

Website stats reports in MonsterInsights

For detailed instructions, see our article on how to install Google Analytics in WordPress.

How to Optimize Your WordPress Blog for SEO

Most beginners don’t optimize for SEO when creating a blog. SEO or search engine optimization helps users find your blog in search engines. If you want more traffic, then it’s crucial that you optimize your blog for SEO from the beginning.

To get started, first you need to install and activate the Yoast SEO plugin. It is the complete WordPress SEO plugin that will help you optimize your blog.

Upon activation, you will see a new menu item labeled ‘SEO’. Clicking on it will take you to the plugins settings page.

Yoast SEO settings

The plugin comes with a quick configuration wizard to help you walk through the set up. You can also follow the instructions in our Yoast SEO guide for manual set up.

We also recommend you to follow our complete step by step WordPress SEO guide to set up your blog’s SEO.

More WordPress Plugins and Customizations

There are a ton of others WordPress plugins that you can install. Often beginners find it a bit overwhelming to search for the plugins they need.

At WPBeginner, we often feature the best WordPress plugins to help you add the functionality that you need.

Here is our expert pick of the best WordPress plugins that you should check out.

If you are curious about the plugins and tools we use on our site, then check out WPBeginner’s Blueprint. It has all the plugins and tools that we use on the WPBeginner blog.

Need more recommendations? See our expert-pick of the must have WordPress plugins and tools for all websites (hand-picked by our founder, Syed Balkhi).

Step 6. Making Money From Your Blog

Now that you’ve created your blog and customized it to your liking, you are probably wondering how can I actually make money from my blog?

There are a lot of different ways to successfully monetize your blog. However there is no such thing as a get rich quick scheme.

Don’t be fooled by the pictures of expensive cars and mansions because those are all fake.

Unlike other “make money online” articles, we have created the most comprehensive guide on how to make money from your blog using WordPress.

Make Money Online Blogging with WordPress

That’s a 4000+ word guide that everyone who want to make money with their blog needs to read. We have shared our 15+ years of online wisdom in that ultimate guide.

As long as you’re willing to put in the hard work and effort, you’ll reap the reward. Remember, there are no shortcuts.

Here are some of the best ways to make money from your blog.

1. Google AdSense

Google AdSense

Many bloggers make money by showing ads on their blog. If you make a blog with monetization in mind, then Google AdSense is the best way to do this.

It is the largest advertising platform for bloggers and publishers. Acting as a middleman between you and the advertiser, Google allow advertisers to bid for keywords matching your content. This allows you to get the best rates possible for the ads.

For more details, see our article on how to properly add Google AdSense to your WordPress blog.

2. Affiliate Marketing

Affiliate Marketing

Affiliate marketing is the second most commonly used monetization strategy among bloggers. Basically, you recommend your favorite products / services to your readers, and when they make a purchase you get a referral commission.

The key in affiliate marketing is to recommend high-quality products and services that you already use and trust. There are plenty of affiliate marketing plugins and tools for WordPress that can help you make more money when promoting affiliate products.

We also have a complete step by step affiliate marketing guide for beginners, that will help you get started.

3. Online Store

Add an online store to your WordPress blog

Many bloggers make money by selling things directly from their blog. This could be physical products, digital downloads like ebooks, artwork, music, and more. Some bloggers even offer consulting services.

We recommend using WooCommerce because it is the best eCommerce plugin for WordPress. It is also the most commonly used eCommerce platform in the world.

For detailed instructions, see our guide on how to easily create an online store using WordPress.

On top of the 3 methods above, you can do so much more with your WordPress blog. You can make WordPress blogs specifically for reviews, fashion blogging, food blogging with recipes, and more. Each of these blog types brings you more unique opportunities to make money.

You can also turn your blog into a membership site to offer premium content and courses.

Step 7. Mastering WordPress

Business Learning and Support

WPBeginner is the largest free WordPress resource site for beginners.

At WPBeginner, our main goal is to provide cutting-edge helpful WordPress tutorials that are easy to understand for small businesses, bloggers, and non-techy WordPress website owners (see more about us).

To expand your WordPress knowledge, you should check out:

  • WPBeginner Dictionary – The best place for beginners to start and familiarize themselves with the WordPress lingo
  • WPBeginner Videos – New to WordPress? Watch these 23 videos to master WordPress.
  • WPBeginner Blog – The central place for all our WordPress tutorials.

For more discussions, you may want to join our free Facebook group WPBeginner Engage. With more than 24,000 members, the group is focused on helping beginners and non-techy users do more with WordPress.

You can also subscribe to WPBeginner’s YouTube Channel where we regularly share video tutorials to help you learn WordPress.

Lastly, you can use Google to type your question and add WPBeginner in front of it. Our users find this trick to be always helpful because it makes it easy for you to find the RIGHT answer for your WordPress questions.

In case you don’t find an answer to your question, don’t worry. Simply use our contact form to send us a message. Our always helpful, full time WPBeginner support team, will be happy to assist. We love helping users get started with WordPress.

Frequently Asked Questions (FAQs)

Having helped thousands of people start a blog, we have answered quite a lot of questions. Below are the answers to the most frequently asked questions about creating a blog.

Can I create a blog without WordPress?

Yes, there are several other blogging platforms available. We have compared them all, and WordPress is by far the best solution in the market to make a blog with complete ownership and freedom.

Can I build a blog without hosting?

No, that’s not possible. Web hosting is where your website files are stored. All websites need web hosting.

How much does it cost to start a blog?

The cost depends on the add-ons that you buy. We have a complete guide on how much does a WordPress website cost as well as tips on how to save money.

Can I create a blog without my parents knowing about it?

Yes. You can make your WordPress blog private and hide it from the internet. Here is a step by step guide on how to make your WordPress blog completely private.

Can I start a WordPress blog and make money with Google Adsense?

Yes, you can use your WordPress blog to earn money from Google AdSense. We have a step by step guide on how to add Google AdSense in WordPress.

How can I create a blog and remain anonymous?

If you want to have a public-facing blog but want to remain anonymous, then you need to make sure that your domain has WHOIS privacy turned on. Often people use a pseudonym / nickname to write under. You should also create a unique email just for your blog. It goes without saying, don’t post your pictures or anything on the blog. For more detailed instructions, see our article on how to blog anonymously using WordPress.

How do I add a podcast to my WordPress blog?

WordPress makes it super easy to start a blog and add a podcast to it. We have a step by step guide on how to start a podcast with WordPress.

How do I come up with blogging ideas to write about?

Here’s an excellent guide that has 103 blog post ideas that you can write about today. Here’s another guide on 73 types of blog posts that are proven to work.

You can also follow this tutorial from Blogtyrant on how to write a good blog post (12 expert tips) which will help you write great content.

Can I build a blog in my own language?

Yes, you can use WordPress in other languages. You can select your language during installation or from Settings page in WordPress admin area. WordPress is fully translated in more than 56 languages and partially translated into dozens of other languages. Many top WordPress themes and plugins are also available in multiple languages. You can also translate a theme or a plugin that you want to use on your website.

How do I create a blog in multiple languages?

Want to start a blog in Hindi, Spanish, or multiple languages? Here’s a step by step guide on how to create a multilingual website in WordPress.

Can I design a blog with no coding skills?

Absolutely. You don’t need any programming, coding, or design skills to create a professional-looking WordPress blog.

WordPress themes are easy to customize and you can just point and click to set up your theme. There are WordPress themes like Astra which comes with ready-made starter websites that you can import with one-click.

There are other powerful themes like Divi which give you complete drag & drop design options for customizing your blog.

Then there are powerful drag and drop page builders like Beaver Builder and Divi builder that works with any WordPress theme. You can use it to just drag and drop items and design your own pages.

You can even create your own custom theme without writing any code.

Can I add a photography gallery to my blog?

Yes, WordPress comes with a built-in gallery feature that makes it easy for you to add photo galleries in your blog posts.

Professional photographers can also use premium WordPress gallery plugins to better showcase their photos and even sell photos to make money from their photography business.

How can I create a professional email address for my blog?

If you’re serious about your blog, then we highly recommend that you create a professional business email address (it’s free).

All successful bloggers use professional email address to stand out and make better partnership deals to grow their blog.

We hope that you found our tutorial on how to start a WordPress blog to be helpful. You may also want to check out our article on 19 actionable tips to drive traffic to your new WordPress site.

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 How to Start a WordPress Blog the RIGHT WAY in 7 Easy Steps (2020) appeared first on WPBeginner.


January 16, 2020 at 04:00PM

Wednesday, January 15, 2020

How to Add Wholesale Pricing in WooCommerce (Step by Step)

Do you want to setup wholesale pricing in WooCommerce for bulk purchases and wholesale buyers? By default, WooCommerce only allows you to set normal pricing for a product.

In this article, we will show you how to easily setup WooCommerce wholesale pricing for customers who want to place bulk orders.

Setting up wholesale pricing discounts in WooCommerce

Who Needs to Setup WooCommerce Wholesale Pricing

Online stores that can fulfill large quantity orders may want to set up wholesale pricing for bulk buyers as well as retail prices for other customers.

You can also use the wholesale pricing if you want to offer discounts to dropshipping businesses.

Now the problem is that by default WooCommerce does not allow you to set up different pricing options based on quantity or customer type.

This means your wholesale customers will have to manually place their orders and negotiate discounts. This is not very efficient and will cause delays which would affect their experience in your store.

That being said, let’s take a look at how to easily set up WooCommerce wholesale pricing and allow wholesale customers to quickly place their orders.

Setting up Wholesale Pricing for WooCommerce

For this tutorial, we’ll be using the WooCommerce Wholesale Suite. It is a suite of three plugins that allow you to sell wholesale products on your WooCommerce store.

First thing you need to do is install and activate the Wholesale Prices plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you need to visit Settings » WWS License page to enter your license key. you can find this information under your account on the plugin website.

Enter license key

Next, you need to edit a product in WooCommerce or create a new one.

On the product edit screen, scroll down to the ‘Product Data’ section. From here you can set the retail price for your product like you would normally do.

Below that, you’ll find an option to set the wholesale price for the product and the minimum quantity required to unlock wholesale pricing.

Wholesale pricing

If you want to strictly implement the minimum order quantity for wholesale customers, then you can set the product’s Wholesale Order Quantity Step to 1.

Setting up Quantity Based Wholesale Pricing

Now, let’s suppose you want to offer different pricing for even higher quantity. WooCommerce Wholesale Pricing allows you to do that as well.

On the product edit page, scroll down to the pricing section and check the box next to ‘Enable further wholesale pricing discounts based on quantity purchased’ option.

Quantity based pricing

This will show the quantity based pricing setting. You can select the wholesale customer role and then enter a starting quantity and end quantity. Finally, add pricing for orders falling between those quantities.

Once you’re done, click on the ‘Add Quantity Discount Rule’ button.

Repeat the process if you need to add more rules for quantity based pricing. You can now save your product or publish it.

Viewing Wholesale Product Prices

By default, wholesale product pricing is available to users with the ‘Wholesale Customer’ user role. This means logged in wholesale customers will see the wholesale pricing on the product page.

For testing purposes, you can create a new user account by visiting Users » Add New page and select ‘Wholesale Customer’ as the user role.

Wholesale customer

After that, you need to log in with the new user account and go to the product you edited earlier. You’ll find the wholesale pricing listed there along with regular pricing.

Wholesale product pricing

Setting up Global Discounts for Wholesale Customers

Normally, you would add a wholesale price for each product manually. However, the WooCommerce Wholesale Prices plugin also allows you to set global discounts for wholesale customers.

Simply head over to WooCommerce » Settings page and switch to the Wholesale Prices tab. From here you need to click on the Discount link.

Global discount

Next, you need to select the wholesale customer role and add a discount value in percentage. Once done, click on the Add Mapping button to save the discount.

This global discount will only be applied to products that don’t have any wholesale pricing set up. Wholesale customers would be able to take advantage of the discount regardless of product quantity.

Setting up Quantity Based Global Discount

If you want to offer a global quantity based discount, then you can set it up on the ‘Discount’ page under plugin settings.

Simply select the wholesale customer role and add the start / end quantity with the discount value in percentage.

Quantity based global discount

Next, click on the Add Mapping button to save your discount rule.

Creating Wholesale Customer Roles

Not all wholesale customers are the same. Some may order more often and in higher quantities than others. Wouldn’t it be nice if you can distinguish between existing wholesale customers?

WooCommerce Wholesale Prices allows you to do that by creating wholesale customer roles.

By default, the plugin comes with the Wholesale Customer user role which you can use for all your wholesale customers. To create more roles, go to WooCommerce » Wholesale Roles page.

Wholesale user roles

You can now select the user role on the Global discount settings or on the product pages to offer different pricing options.

We hope this article helped you set up WooCommerce wholesale pricing on your eCommerce store. You may also want to see our list of best WooCommerce plugins, best WooCommerce themes, and best WooCommerce hosting to grow your business.

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 How to Add Wholesale Pricing in WooCommerce (Step by Step) appeared first on WPBeginner.


January 15, 2020 at 06:40PM

Tuesday, January 14, 2020

How to Fix the Error Establishing a Database Connection in WordPress

Are you seeing the ‘Error establishing a database connection’ notice on your WordPress website? It is a fatal error that makes your WordPress website inaccessible to the users.

This error occurs when WordPress is unable to make a connection to the database. A number of things can affect your WordPress database connection which makes it a bit difficult for beginners to troubleshoot.

In this article, we will show you how to easily fix the error establishing a database connection in WordPress.

Fixing the database connection error in WordPress

What Causes Error Establishing a Database Connection in WordPress?

The ‘Error establishing a database connection’ issue can be caused by incorrect database information in your WordPress settings, corrupt database, or an irresponsive database server.

Database connection error in WordPress

A database is a software which makes it easy to store, organize, and retrieve data into other software.

As a content management system, WordPress uses a database to store all your content and other website data. It then connects to the database each time someone visits your website.

WordPress needs the following information for connecting to the database:

  • Database name
  • Database username
  • Database password
  • Database server

This information is stored in your WordPress configuration file called wp-config.php.

If any of these items are incorrect, WordPress would fail to connect to your database server, and you’ll see the ‘Error establishing a database connection’ error.

It is one of the most common WordPress errors. Apart from incorrect credentials, this error can also appear if the database server is down, or the database files are corrupt.

Let’s take a look at how to fix error establishing database connection issue in WordPress with step by step troubleshooting.

1. Check Your WordPress Database Credentials

The most common reason for database connection error in WordPress is incorrect database credentials. If you have recently moved your WordPress site to a new host, then this could be the most likely reason.

Your WordPress database credentials are stored in the wp-config.php file. It is the WordPress configuration file that contains important WordPress settings including database information.

If you have not edited wp-config.php file before, then take a look at our guide on how to edit wp-config.php file in WordPress.

You’ll be looking for the following lines in the wp-config.php file.


// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );
/** MySQL database username */
define( 'DB_USER', 'username_here' );
/** MySQL database password */
define( 'DB_PASSWORD', 'password_here' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

You need to make sure that the information for the database name, username, password, and database host is correct.

You can confirm this information from your WordPress hosting account dashboard. Simply log in to your hosting account and click on MySQL databases under the database section.

Database information

This will take you to the database management page in your hosting dashboad. From here, you can find out your database name and the username.

Database name and username

Below that you will find the database users and links to change the user password.

Changing database user password

Once you have confirmed your database name, username, and password, you can change that information in your wp-config.php file if needed.

After that, try visiting your website again to see if the database connection error has gone.

If you can still see the error, then this means that something else is wrong. Continue reading for more troubleshooting steps.

2. Check Your Database Host Information

If you are confident that your database name, username, and password information is correct, then you may want to make sure that you are using the correct database host information.

Most WordPress hosting companies use localhost as your database host. However, some managed WordPress hosting companies use separate servers to host databases. In that case, your database host information will not be localhost.

You need to contact your WordPress hosting company to confirm your database host information.

3. Repair WordPress Database

If you are getting a different error on the wp-admin, for instance, something like “One or more database tables are unavailable. The database may need to be repaired”, then you need to repair your database.

You can do this by adding the following line in your wp-config.php file. Make sure to add it just before ‘That’s all, stop editing! Happy blogging’ line wp-config.php.

define('WP_ALLOW_REPAIR', true);

Once you have done that, you can see the settings by visiting this page: https://ift.tt/1ab1nSy

Repair WordPress database

Note: the user does not need to be logged in to access the database repair page. Once you are done repairing and optimizing your database, make sure to remove this code from your wp-config.php.

4. Check if Your Database Server is Down

If everything seems to be correct, and WordPress still cannot connect to the database, then your database server (MySQL server) may be down.

This could happen due to heavy traffic on a server. Basically, your host server just cannot handle the load (especially when you are on shared hosting).

Your site will get really slow and for some users it may even output the error. So the best thing you should do is get on the phone or live chat with your hosting provider and ask them if your MySQL server is responsive.

If you have other websites running on the same server, then you can check those sites to confirm that your SQL server is down.

If you do not have any other site on the same hosting account, then simply go to your hosting dashboard and try to access phpMyAdmin and connect the database.

If you can connect, then we need to verify if your database user has sufficient permission. Create a new file called testconnection.php and paste the following code in it:

<?php
$link = mysqli_connect('localhost', 'username', 'password');
if (!$link) {
die('Could not connect: ' . mysqli_error());
}
echo 'Connected successfully';
mysqli_close($link);
?>

Make sure to replace the username and password. You can now upload this file to your website and access it via web browser.

If the script connected successfully, then it means that your user has sufficient permission, and there is something else that is wrong.

Go back to your wp-config file to make sure that everything there is correct (re-scan for typos).

Other Solutions That Have Worked for Users

If the above-mentioned troubleshooting tips failed to fix the database connection error on your website, then you may try these additional steps.

Reported by our users, these steps have helped some users resolve the database connection error on their websites.

1. Update WordPress Site URL

Try updating the WordPress site URL using phpMyAdmin. Simply access phpMyAdmin from your hosting account dashboard, and select your WordPress database.

Running SQL in phpMyAdmin

After that click on the SQL menu on the top and enter the following MySQL query.

UPDATE wp_options SET option_value='YOUR_SITE_URL' WHERE option_name='siteurl'

Don’t forget to provide your own site URL and change wp_options to your own table name as you may have changed the WordPress table prefix.

2. Rebooting Web Server

Users on dedicated servers, local server, and virtual private servers (VPS) can try rebooting their servers.

This will restart your web and database server which may fix some temporary glitches causing the error.

3. Ask for help

If everything else fails, then you may need to contact your web hosting company. All good WordPress hosting companies will help you troubleshoot the problem, point you in the right direction, or even fix it for you.

You can also hire WordPress developers from Codeable that can help you fix this issue for reasonable rates. The best part is that these developers are highly-vetted by Codeable team, so you know they can be trusted.

We hope this article helped you fix the error establishing a database connection in WordPress. You may also want to see our WordPress troubleshooting guide for tips on resolving WordPress issues on your own.

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 How to Fix the Error Establishing a Database Connection in WordPress appeared first on WPBeginner.


January 14, 2020 at 03:00PM

Monday, January 13, 2020

How to Save Contact Form Data in the WordPress Database

Recently one of our readers asked if it’s possible to save WordPress contact form data in the database?

Typically most popular WordPress form plugins will send a notification email to administrators after a form entry is submitted on the website.

But what happens to this data after it’s sent? In this article, we will share how to save contact form data in the WordPress database, and what does it actually mean.

Saving your contact form data in your WordPress database

Contact Form and the WordPress Database (Behind the Scenes)

When a visitor submits a contact form on your WordPress site, the most prominent visible action that you as a website owner will see is an email notification in your inbox that contains all the details that specific visitor submitted.

However behind the scenes, most WordPress form plugins will also store this data in your WordPress database.

A WordPress database is a system of storing and fetching data in an organized way. This allows plugin developers to manage data in a programmable way.

As a user, if you wanted to display the data in your WordPress database, then you would need to login to your WordPress hosting account and go to the phpMyAdmin tool.

For example, if you’re using Bluehost, then the link to phpMyAdmin is at the bottom of the control panel under Helpful Links » Advanced » phpMyAdmin.

Once you’re in phpMyAdmin, you’d need to select your WordPress database, then click on the database table of your respective WordPress form plugin. Since we use WPForms, this is our form table: wp_wpforms_entries.

The wp_wpforms_entries and wp_wpforms_entry_meta tables shown in the phpMyAdmin list

Once you’ve clicked on the table, you’ll find all your form entries in the fields column.

Contact Form Data Fields in WordPress Database phpMyAdmin View

Giving the looks of it, you will agree with us when we say that this is not the most user-friendly way to see data.

This is why most premium WordPress form plugins come with a user-friendly entry management solution that allows you to access form entries inside your WordPress dashboard.

Yes, all contact form data is still stored in your WordPress database, but you can view it in a user-friendly interface like your WordPress admin instead of the screenshot above.

Let’s take a look at an example of what it looks like when using WPForms, which is the fastest growing premium WordPress form plugin, and it’s currently being used by over 3 million websites.

How to Manage Contact Form Entries in WordPress

For the sake of this example, we will be using WPForms because that’s the plugin built by our team, and it is what we use on WPBeginner. However similar process exists in other popular WordPress form plugins like Formidable Forms, and others.

First, you will of course need to create a contact form with WPForms. If you need instructions for this, then you can follow our step by step guide on how to create a contact form in WordPress.

After you have added the contact form on your website, you need to go ahead and make a test entry submission. Here’s an example of our simple contact form:

A simple contact form, showing fields for Name, Email, and Comment or Message

Once you have filled it out with sample information, click on Submit.

This will cause two things to happen. First, it will send you, the site admin, an email with all the information from the form. Second, it will store the contact form data in your WordPress database which you can view on the WPForms » Entries section in the WordPress dashboard.

The WPForms Entries Overview page, showing a graph and a table with the form name and number of entries

From this screen, you can click on your form’s name, or the count under the All Time to see your entry.

Table showing entered form data for name, email, and comment or message

The field labels (in this case, Name, Email, and Comment or Message) are listed at both the top and the bottom of the table.

The entry management screen also gives you an ability to star (favorite) entries in the table, mark them as read, or even delete them.

You can click on the View link next to the entry item to see more details such as date of submission, other contact form fields, etc.

The View link, indicated by a red arrow, that you click to view the contact form entry details

On the WPForms entry details page, you can add notes about the contact form entry, print or export it, star it, and more.

The page showing all the details about the contact form entry

As a user, this interface is much more user friendly way to view the contact form data stored in a WordPress database.

Bonus Tip: How to Disable Form Data from being Stored in WordPress Database

In some cases, you may not want to store your contact form data in a WordPress database. WPForms also allows you to do that. All you need to do is edit the respective WordPress form, and it will open the WPForms form builder.

You need to go to the Settings » General tab inside the builder and scroll to the bottom. You need to make sure to check the option that says: Disable storing entry information in WordPress.

Disable Entry Storing on WPForms

After that, simply click on the Save Button and you’re done.

Now you need to go back to this form and submit a test entry to make sure that you’re receiving email notifications. This is very important because the contact form entry will NOT be stored in the database when you have the above setting checked.

If you’re running into the WordPress not sending email issue, then you need to install and activate WP Mail SMTP plugin. It helps you improve WordPress email deliverability by letting you connect with top SMTP providers like Amazon SES, SendGrid, etc.

That’s all. We hope this article helped you learn how to save contact form data in the WordPress database. You may also want to see our guide on the best email marketing services to help increase your website traffic and sales.

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 How to Save Contact Form Data in the WordPress Database appeared first on WPBeginner.


January 13, 2020 at 06:06PM