Categories
Website

How to Create a Dropdown Menu in WordPress (Beginners Guide)

Do you want to make a dropdown menu and add it to your WordPress website?

A dropdown menu shows a list of links as you take your mouse over an item on the menu.

We use a dropdown menu on WPBeginner, go ahead and take your mouse over the navigation menu on top.

In this beginner’s guide, we will show you how to easily create a dropdown menu in WordPress with step by step instructions.

Creating a dropdown menu in WordPress

Why Use Dropdown Menus in WordPress?

WordPress comes with a built-in menu management system that allows you to easily add navigation menus to your WordPress site.

Navigation menus are links to the main pages of your website that usually appear on the top as a horizontal row right next to the website’s logo.

Typical navigation menu with a horizontal row of links

If you are starting a blog or creating a website with only a few pages, then you can add them in the single row.

However, if you run an online store or a large website, then you may want to add more links to the navigation menu.

Dropdown menus help you solve the limited space issue by showing menu links only when users bring their mouse over to a parent item. They also allow you to organize the menu structure by topics or hierarchy.

Dropdown menu example

Lastly, they look pretty nice too.

That being said, now let’s take a look at how you can easily create WordPress dropdown menus add them to your website.

Step 1. Choosing a Theme with Dropdown Menu Support

WordPress comes with a built-in menu management system but displaying those menus is entirely dependent on your WordPress theme.

Almost all WordPress themes support dropdown menus by default. However, some themes may not have proper menu support.

You need to make sure that you are using a WordPress theme that supports dropdown menus.

How do you know if the theme you are using supports the dropdown menu?

You can simply visit the theme’s website where you’ll find a link to the theme’s demo. From there you can see if the demo is showing a dropdown menu in the navigation menu.

If it is not, then you’ll need to find a WordPress theme that does.

See our guide on how to choose the perfect WordPress theme for your website.

Here are a few excellent themes that support the dropdown menu out of the box.

  • Astra – It is a multipurpose WordPress theme that comes with several starter sites and tons of features.
  • StudioPress themes – Built on top of genesis theme framework, these professional themes are highly optimized for performance.
  • OceanWP – A popular WordPress theme that is suitable for all kind of websites.
  • Ultra – Powered by Themify builder this drag and drop WordPress theme comes with beautiful templates and flexible theme options.
  • Divi – popular theme by Elegant Themes that uses the Divi page builder and comes with tons of drag & drop features including dropdown menus.

That being said, now let’s take a look at how to create a dropdown WordPress menu.

Step 1. Creating a Navigation Menu in WordPress

If you have already set up a navigation menu on your website, then you can skip to the next step.

Let’s create a simple menu first.

Go to Appearance » Menus page and click on the ‘Create a new menu’ link at the top.

Create a menu

Next, you need to provide a name for your navigation menu. This name will not be publicly visible on your website. The purpose of menu name is to help you identify the menu inside the WordPress admin area.

Menu name

Enter a name for your menu and then click on the ‘Create Menu’ button.

WordPress will now create a new empty menu for you.

Let’s add the top links to the navigation menu. These items will appear in the top row of your menu.

Simply select the pages you want to add from the left column and click on the ‘Add to menu’ button. You can also select blog posts, categories, or add custom links.

Add pages to menu

You will now see those pages appear in the right column under your new menu.

Step 2. Adding Sub-Items to a Menu

Sub-items are the items that will appear inside the dropdown menu. Depending on how you want to organize your menus, you can add them under any of the existing items.

For the sake of this tutorial, we will be adding categories under the blog link.

Simply select the items you want to add from the left column and then click on the ‘Add to menu’ button. Your items will now appear in the right column.

New menu items added to the menu

However, these links will appear as regular items. We need to make them a sub-item of a parent menu.

You can simply drag and drop a menu item and place it under the parent item. Move it slightly to the right, and it will become a sub-item.

Adding sub menu items to create a dropdown menu

Repeat the process for all links you want to show under the dropdown menu.

Once you are done, don’t forget to click on the ‘Save menu’ button to store your changes.

Step 3. Publish Your Dropdown Menu

If you are editing a menu that’s already live on your website, then it will start appearing on your website right away.

However, if it is a new menu item, then you now need to choose a theme location to display this menu.

WordPress themes can show menus at different locations. Each theme defines their own menu locations, and you can select which menu you want to display there.

You’ll find this option in the right column under ‘Menu settings’. Select an option next to the ‘Display location’ setting and click on the ‘Save menu’ button.

Choose theme location

You can now visit your website to see your dropdown menu in action.

Dropdown menu preview

Tips on Creating Interactive Dropdown Menus

Navigation menus are important because this is the first place your users will look if they want to see specific information.

Using them correctly will help your users find their way around your website. It will also help you get more pageviews, conversions, and sales on your website.

Here are a few tips on making your navigation menus more interactive with dropdown menus.

1. You can create multi-level dropdown menus

Making a link a sub-item of another link makes it appear in the dropdown menu. You can also add a sub-item below another sub-item to create multi-level dropdown menus.

Multi level menus

Your theme would automatically show them as a sub-menu inside the dropdown.

Multi-level dropdown menu

2. You can also create multiple dropdown menus

You can create a dropdown under any top link in your menu. You can even add multiple dropdown menus in your main navigation menu.

Multiple dropdown menus in the primary menu

3. Create menus with a live preview

If your menu gets too complicated, then you can switch to the visual preview. Go to Appearance » Customize to launch the live theme customizer.

From there, click on the ‘Menus’ tab and then select your navigation menu. You’ll now see a drag and drop menu editor in the left column with a live preview of your site in the right panel.

Customize WordPress menus with a live preview

4. Creating a large mega menu as dropdown in WordPress

The dropdown menus only show one dropdown at a time. What if you wanted to show the full structure of your website as a mega menu that only appears when users hover on the main menu?

Mega menu example

Mega menus do appear as a dropdown menu, but they can show a lot more links, sub-menus, and more. For detailed instructions, see our step by step tutorial on how to create a mega menu in WordPress.

We hope this article helped you learn how to easily create a dropdown menu in WordPress. You may also want to see our guide how to create a sticky floating navigation menu in WordPress and how to add image icons to navigation menus in WordPress.

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.



Source link

Categories
Website

Beginner’s Guide to WordPress Database Management with phpMyAdmin

WordPress is written using PHP as its scripting language and MySQL as its database management system. In order to use WordPress, you don’t really need to learn either of them.

However, a very basic understanding of the two could help you troubleshoot problems as well as increase your understanding of how WordPress works (behind the scenes).

In this article, we will explain how WordPress uses the database including an intro to default WordPress database tables.

We will also show you how to manage a WordPress database using phpMyAdmin which will include creating database backups, optimizing the WordPress database, and more.

How to manage WordPress database using phpMyAdmin

This is a comprehensive guide on WordPress database management, so we have added a table of contents for easier navigation:

What is a Database and How WordPress Uses it?

A database is a system of storing and fetching data in an organized way. Database allows software to manage data in a programmable way.

For example: WordPress uses PHP (programming language) to store and retrieve data from the database.

The information stored in a WordPress database includes posts, pages, comments, categories, tags, custom fields, users, and other WordPress settings. We will elaborate on this later in the tutorial when we cover all WordPress database tables.

When you first install WordPress, it asks you to provide a database name, host, username, and password. This information is stored in the configuration file called wp-config.php.

WordPress database information

During the installation, WordPress uses the information you provide about the database to create tables and store default installation data inside those tables.

After the installation, WordPress runs queries to this database to dynamically generate HTML pages for your website or blog.

This is what makes WordPress extremely powerful because you don’t have to create a new .html file for each page that you want to create. WordPress handles everything dynamically.

Where is my WordPress database stored?

WordPress uses MySQL as its database management system, which is a software installed on your WordPress hosting server. Your WordPress database is also stored on the same server.

This location however is not accessible on most shared hosting environments. However, if you are on a VPS hosting plan or a dedicated server, then you can use command line tools to locate the database.

Most often it is located at the following path:

/var/lib/mysql/your_database_name

However, this could differ from one hosting provider to another.

It is important to keep in mind that you don’t really need to access the database file itself. You can use other tools like phpMyAdmin to manage your database.

What is phpMyAdmin?

PhpMyAdmin is a web-based software that allows you to manage MySQL databases using your web browser. It offers an easy to use interface that allows you to run MySQL commands and database operations.

You can also use it to browse and edit database tables, rows, and fields. It also allows you to import, export, or delete all data inside a database.

How to Access PhpMyAdmin?

PhpMyAdmin comes pre-installed with all top WordPress hosting companies. You can find it under the Databases section of your hosting account’s cPanel dashboard. Below is an example screenshot from Bluehost control panel:

phpMyAdmin in cPanel

Depending on your hosting provider, your cPanel interface may look different than the above screenshot. You would still be able to find phpMyAdmin icon under the databases section.

Clicking on it will open the phpMyAdmin interface where you can select your WordPress database from the left column. After, that phpMyAdmin will display all tables in your WordPress database.

PhpMyAdmin dashboard

Let’s take a look at the WordPress database tables.

Understanding WordPress Database Tables

Each WordPress installation has 12 default tables in the database. Each database table contains data for different sections, features, and functionality of WordPress.

Looking at the structure of these tables, you can easily understand where different parts of your website are stored. Currently, a default WordPress installation creates the following tables:

Note: wp_ before each table name is the database prefix you choose during the installation. It can be different if you changed it at the time of installation.

wp_commentmeta : This table contains meta information about comments posted on a WordPress website. The table has four fields meta_id, comment_id, meta_key, and meta_value. Each meta_id is related to a comment_id. One example of comment meta information stored is the status of comment (approved, pending, trash, etc).

wp_comments : As the name suggests this table contains your WordPress comments. It contains comment author name, url, email, comment, etc.

wp_links : To manage blogrolls create by earlier versions of WordPress or the Link Manager plugin.

wp_options : This table contains most of your WordPress site-wide settings such as: site url, admin email, default category, posts per page, time format, and much much more. The options table is also used by numerous WordPress plugins to store plugin settings.

wp_postmeta : This table contains meta information about your WordPress posts, pages, and custom post types. Example of post meta information would be which template to use to display a page, custom fields, etc. Some plugins would also use this table to store plugin data such as WordPress SEO information.

wp_posts : The name says posts but actually this table contains all post types or should we say content types. This table contains all your posts, pages, revisions, and custom post types.

wp_termmeta : This table allows developers to store custom metadata for terms under their custom taxonomies. For example, WooCommerce uses it to store metadata for product attributes and categories.

wp_terms : WordPress has a powerful taxonomy system that allows you to organize your content. Individual taxonomy items are called terms, and they are stored in this table. For example, your WordPress categories and tags are taxonomies, and each category / tag inside them is a term.

wp_term_relationships : This table manages relationship of WordPress post types with terms in wp_terms table. For example this is the table that helps WordPress determine post X is in Y category.

wp_term_taxonomy : This table defines taxonomies for terms defined in wp_terms table. For example, if you have a term “WordPress Tutorials“, then this table contains the data that says it is associated with a taxonomy called category. In short, this table has the data that helps WordPress differentiate between which term is a category, which is a tag, etc.

wp_usermeta : Contains meta information about registered users on your website.

wp_users : Contains user information like username, password, user email, etc.

Managing WordPress Database using phpMyAdmin

Your WordPress database contains important WordPress settings, all your blog posts, pages, comments, and more. You need to be extremely careful when using phpMyAdmin, or you may end up accidentally deleting important data.

As a precaution, you should always create a complete database backup. This would allow you to restore your database the way it was before.

Let’s take a look at how to easily create a WordPress database backup.

Creating a WordPress Database Backup using phpMyAdmin

To create a backup of your WordPress database from phpMyAdmin, click on your WordPress Database. On the top menu, click on the Export tab.

Export WordPress database

In newer versions of phpMyAdmin, it will ask you for an export method. The quick method will export your database in a .sql file. In the custom method, it will provide you with more options and ability to download backup in compressed zip or gzip archive.

We recommend using the custom method and choosing zip as the compression method. The custom method also allows you to exclude tables from the database.

Let’s say if you used a plugin that created a database table, and you are no longer using that plugin, then you can choose to exclude that table from the backup if you want.

Compression method

Your exported database file can be imported back into a different or the same database using phpMyAdmin’s import tab.

Creating a WordPress Backup using a Plugin

Keeping regular backups of your WordPress site is the best thing you can do for your WordPress security. While the WordPress database contains the majority of your site information, it still lacks several fairly important elements such as template files, images, uploads, etc.

All your images are stored in the uploads folder in your /wp-content/ directory. Even though the database has the information which image is attached to a post, it is useless if the image folder doesn’t have those files.

Often beginners think that the database backup is all that they need. It is NOT true. You need to have a full site backup that includes your themes, plugins, and images.

While most hosting companies claim they have daily backups, we recommend that you keep backups yourself just in case.

Note: If you are on a managed WordPress hosting solution like WPEngine, then they do create daily backups.

For the majority of us who are not on WPEngine, you should use a WordPress backup plugin to set up automated WordPress backups on your site.

Importing a WordPress Database Backup via phpMyAdmin

PhpMyAdmin also allows you to easily import your WordPress database. Simply launch phpMyAdmin and then select your WordPress database.

Next, you need to click on the ‘Import’ link from the top menu.

Import database via phpMyAdmin

On the next screen, click on the Choose file button and then select your database backup file you downloaded earlier.

PhpMyAdmin will now process your backup file upload and import it into your WordPress database. Once finished, you will see a success message.

Database imported successfully

Optimizing your WordPress Database in phpMyAdmin

After using WordPress for a while, your database becomes fragmented. There are memory overheads which increase your overall database size and query execution time.

MySQL comes with a simple command that allows you to optimize your database. Simply go to phpMyAdmin and click on your WordPress database. This will show you a list of your WordPress tables.

Click on the check All link below the tables. Next to it, there is a “With Selected” drop down, you need to click on it and choose Optimize table.

Optimize WordPress database tables

This will optimize your WordPress database by defragmenting selected tables. It will make your WordPress queries run a little faster and slightly reduce the size of your database.

Fixing WordPress Issues using PhpMyAdmin

As we mentioned earlier, phpMyAdmin is a handy tool for troubleshooting and fixing some common WordPress errors and issues.

Let’s check out some common WordPress issues that can be easily fixed using phpMyAdmin.

Reset WordPress Password Using PhpMyAdmin

If you forgot your WordPress admin password and cannot recover it via lost password email, then this method allows you to quickly reset WordPress password.

First, launch the phpMyAdmin and select your WordPress database. This will display your WordPress database tables where you need to browse next to wp_users table.

Browse user table

Note: Table names in your WordPress database may have a different table prefix than the one we are showing in our screenshot.

You will now see the rows in your WordPress users table. Go ahead and click on the edit button next to the username where you want to change the password.

Edit user

PhpMyAdmin will show you a form with all the user information fields.

You will need to delete the value in the user_pass field and replace it with your new password. Under the function column, select MD5 from the drop-down menu and click on the Go button.

Change user password

Your password will be encrypted using the MD5 hash and then it will be stored in the database.

Congratulations! You have successfully changed your WordPress password using phpMyAdmin.

Now some of you may be wondering why did we select the MD5 hash to encrypt the password.

In the older version, WordPress used MD5 hash to encrypt passwords. Since WordPress 2.5, it started using stronger encryption technologies. However, WordPress still recognizes MD5 to provide backward compatibility.

As soon as you log in using a password string stored as an MD5 hash, WordPress recognizes it and changes it using the newer encryption algorithms.

Adding a New Admin User to WordPress using PhpMyAdmin

Let’s suppose you have access to the WordPress database but not the WordPress admin area. While you can change the admin user password, it will prevent the other admin user from using their account.

An easier solution would be to add a new admin user via phpMyAdmin.

First, you need to launch the phpMyAdmin and then select your WordPress database. This will show your WordPress database tables where you need to click on the ‘Browse’ link next to wp_users table.

Browse user table

phpMyAdmin will now show you the rows inside the wp_users table. Go ahead and click on the ‘Insert’ link from the menu on the top.

Insert new row in WordPress users table

This will bring up a form that you need to fill up to add a new user to your WordPress site.

Fill user form

Here is how you need to fill each field in this form.

  • ID – You can ignore this one as this is automatically generated.
  • user_login – This will be your WordPress username that you’ll use to login.
  • user_pass – This is your WordPress password you need to enter the password and select MD5 in the function column.
  • user_nicename – This is the URL friendly username you can use the as your login.
  • user_email – Enter a valid email address as you may need it to recieve password reset and WordPress notification emails.
  • user_url – Add your website URL or you can leave it blank.
  • user_registered – You need to select the CURRENT_TIME in the function column to automatically insert current time here.
  • user_activation_key – You can leave this field blank as well it is used to approve user registeration.
  • user_status – You can leave this field blank as well.
  • display_name – You can enter the user’s full name as you want to be displayed on the articles. You can also leave it blank.

After filling in the form, click on the Go button to insert it into your WordPress database. PhpMyAdmin will now run the MySQL query to insert the data.

We have added the user, but that user does not have an administrator user role on your WordPress site. This value is saved in another table called wp_usermeta.

Before we can make this user an administrator, we will need to find the user ID. Simply click on the ‘Browse’ link next to wp_users table and you will see a row containing your newly added user with their user ID.

Find user ID

Note down the user ID as you’ll need it in the next step.

Now, let’s open the wp_usermeta table by clicking on the Browse link next to it.

Browsing wp_usermeta table

Next, you need to click on the Insert link at the top to add a new row to the table.

Insert new row to usermeta table

You’ll now see a form to enter a new row. This is where you’ll tell WordPress that the user you created earlier has the administrator user role.

Adding administrator user role via usermeta

Here is how you’ll fill in this form.

  • umeta_id – You need to leave it blank as it is automatically filled in.
  • user_id – Enter the user ID you copied earlier.
  • meta_key – You need to enter wp_capabilities in this field. However, you may need to replace wp_ if your WordPress table names use a different prefix.
  • meta_value – You need to enter the following serialized value:
    a:1:{s:13:"administrator";s:1:"1";}

Finally, click on the Go button to save your changes.

Next, we need to add another row to define the user level. Click on the Insert link on the top menu to add another row to the usermeta table.

Adding the user level meta field

Here is how you’ll fill in this form.

  • umeta_id – You need to leave it blank as it is automatically filled in.
  • user_id – Enter the user ID for your newly added user.
  • meta_key – You need to enter wp_user_level in this field. However, you may need to replace wp_ if your WordPress table names use a different prefix.
  • meta_value – Here you need to enter 10 as the user level value.

Don’t forget to click on the Go button to insert the data.

That’s all, you can now visit the WordPress admin area and log in with your newly added admin user.

Change a WordPress Username via PhpMyAdmin

You may have noticed that while WordPress allow you to change user’s full name or nickname, it does not allow you to change the username.

Now a lot of users end up choosing usernames during the installation that they may later want to change. Here is how you can do this via phpMyAdmin.

Note: there is an easier way to change WordPress username using a plugin.

First, you need to launch the phpMyAdmin from your hosting account’s cPanel dashboard. After that, you need to select your WordPress database.

PhpMyAdmin will show your WordPress database tables. You need to click on the ‘Browse’ link next to wp_users table.

Browse user table

This table will now list all the registered users on your website. Click on the edit link next to the username that you want to change.

Edit user data via phpMyadmin

PhpMyAdmin will now show you the user data. You need to locate the user_login field and change the value to the username you want to use.

Change WordPress username in phpMyAdmin

Don’t forget to click on the Go button to save your changes. You can now visit your website and login with your new username.

Other Useful PhpMyAdmin Tricks

Your WordPress database is the engine behind your website. With phpMyAdmin you can tweak settings to improve performance, fix issues, or simply change things that cannot be changed from inside WordPress admin area.

Following are just a few more tricks you can use with phpMyAdmin.

Securing your WordPress Database

Before we get into this, we want to emphasize that every site can be hacked. However, there are certain measures you can take to make it a little harder.

First thing that you can do to is to change WordPress database prefix. This can significantly reduce the chances of SQL injection attacks on your WordPress database because often hackers target sites in masses where they are targeting the default wp_ table prefix.

You should always choose a strong username and password for your MySQL user. This will make it difficult for someone to get access to your WordPress database.

For WordPress security, we strongly recommend that you use Sucuri. It is the best WordPress security plugin that would catch any attempts at MySQL injection even before it reaches your website.

We hope that this guide helped you learn WordPress database management and how to use phpMyAdmin.

If you are the sort of person who likes to learn how things work behind the scenes, then you would love our guides on how WordPress actually works and how WordPress plugins work.

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.



Source link

Categories
Website

How to Add a Shortcode in WordPress? (Ultimate Guide)

Shortcodes are an easy way to add dynamic content into your WordPress posts, pages, and sidebars.

Many WordPress plugins and themes use shortcodes to add specialized content like contact forms, image galleries, sliders, and more.

In this article, we will show you how to easily add a shortcode in WordPress. We will also show you how to create your own custom shortcodes in WordPress.

Adding a shortcode in WordPress

What are Shortcodes?

Shortcodes in WordPress are code shortcuts that help you add dynamic content in WordPress posts, pages, and sidebar widgets. They are displayed inside square brackets like this:

[myshortcode]

To better understand shortcodes, lets take a look at the background of why they were added in the first place.

WordPress filters all content to make sure that no one uses posts and page content to insert malicious code in the database. This means that you can write basic HTML in your posts, but you cannot write PHP code.

But what if you wanted to run some custom code inside your posts to display related posts, banner ads, contact forms, galleries, etc?

This is where Shortcode API comes in.

Basically, it allows developers to add their code inside a function and then register that function with WordPress as a shortcode, so users can easily use it without having any coding knowledge.

When WordPress finds the shortcode it will automatically run the code associated with it.

Let’s see how to easily add shortcodes in your WordPress posts and pages.

Adding a Shortcode in WordPress Posts and Pages

First, you need to edit the post and page where you want to add the shortcode. After that, you need to click on the add block button to insert a shortcode block.

Adding shortcode block in WordPress

After adding the shortcode block, you can simply enter your shortcode in the block settings. The shortcode will be provided by various WordPress plugins that you might be using such as WPForms for contact forms, OptinMonster for email marketing forms, WP Call button for inserting a click to call button, etc.

Insert shortcode in the block editor

To learn more about using blocks, see our Gutenberg tutorial for more details.

You can now save your post or page and preview your changes to see the shortcode in action.

Adding a Shortcode in WordPress Sidebar Widgets

You can also use shortcodes in WordPress sidebar widgets. Simply visit the Appearance » Widgets page and add the ‘Text’ widget to a sidebar.

Now you can paste your shortcode inside the text area of the widget.

Adding shortcode in sidebar widget

Don’t forget to click on the ‘Save’ button to store your widget settings.

After that, you can visit your WordPress website to see the live preview of the shortcode in the sidebar widget.

Adding a Shortcode in Old WordPress Classic Editor

If you are still using the old classic editor in WordPress, then here is how you can add shortcodes to your WordPress posts and pages.

Simply edit the post and page where you want to add the shortcode. You can paste the shortcode anywhere inside the content editor where you want it to be displayed. Just make sure the shortcode is in its own line.

Shortcode classic editor

Don’t forget to save your changes. After that you can preview your post and page to see the shortcode in action.

How to Add a Shortcode in WordPress Theme Files

Shortcodes are meant to be used inside WordPress posts, pages, and widgets. However, sometimes you may want to use a shortcode inside a WordPress theme file.

WordPress makes it easy to do that, but you will need to edit your WordPress theme files. If you haven’t done this before, then see our guide on how to copy and paste code in WordPress.

Basically, you can add a shortcode to any WordPress theme template by simply adding the following code.


WordPress will now look for the shortcode and display its output in your theme template.

How to Create Your Own Custom Shortcode in WordPress

Shortcodes can be really useful when you want to add dynamic content or custom code inside the WordPress post and pages. However, if you want to create a custom shortcode, then it requires some coding experience.

If you are comfortable with writing PHP code, then here is a sample code that you can use as a template.

// function that runs when shortcode is called
function wpb_demo_shortcode() { 

// Things that you want to do. 
$message = 'Hello world!'; 

// Output needs to be return
return $message;
} 
// register shortcode
add_shortcode('greeting', 'wpb_demo_shortcode'); 

In this code, we first created a function that runs some code and returns the output. After that, we created a new shortcode called ‘greeting’ and told WordPress to run the function we created.

You can now use add this shortcode to your posts, pages, and widgets using the following code:

[greeting]

It will run the function you created and show the desired output.

Now let’s take a look at a more practical usage of a shortcode. In this example, we will display a Google AdSense banner inside a shortcode.


// The shortcode function
function wpb_demo_shortcode_2() { 

// Advertisement code pasted inside a variable
$string .= ' ';

// Ad code returned
return $string; 

}
// Register shortcode
add_shortcode('my_ad_code', 'wpb_demo_shortcode_2'); 

Don’t forget to replace the ad code with your own advertisement code.

You can now use the [my_ad_code] shortcode inside your WordPress posts, pages, and sidebar widgets. WordPress will automatically run the function associated with the shortcode and display the advertisement code.

Shortcodes vs Gutenberg Blocks

We’re often asked by users about the differences between shortcode vs the new Gutenberg blocks.

Basically if you find shortcodes useful, then you’ll love WordPress editor blocks. Blocks allow you to do the same thing but in a more user-friendly way.

Instead of requiring users to add a shortcode for displaying dynamic content, blocks allow users to add dynamic content inside posts / pages with a more intuitive user interface. A lot of popular WordPress plugins are switching to using Gutenberg blocks instead of shortcodes because they’re more beginner friendly.

We have put together a list of the most useful Gutenberg block plugins for WordPress that you may want to try.

If you want to create your own custom Gutenberg blocks, you can follow our step by step tutorial on how to create custom Gutenberg blocks in WordPress.

We hope this article helped you learn how to add a shortcode in WordPress. You may also want to see our guide on the best drag & drop WordPress page builder plugins, and how to create a custom WordPress theme without writing any code.

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.



Source link

Categories
Website

A Step by Step Guide for WordPress [2019]

Dropshipping has become a popular online business idea because it’s easy to setup, requires very little investment, and the market is huge.

Unlike traditional eCommerce business that requires you to manage product inventory and handle shipping logistics, dropshipping allows you to start an online store without managing inventory or dealing with shipping.

In this beginner’s guide, we will walk you through the entire process of setting up a dropshipping business with WordPress. We will also share tips on how to find the best products for dropshipping and how to grow your dropshipping business.

How to start your dropshipping business with WordPress

Since this is a long and detailed dropshipping guide, we have broken it down into different sections that you can navigate to by using the navigation below:

What is Dropshipping?

Dropshipping is an online business where an eCommerce store doesn’t keep the products in stock, meaning no inventory cost. Instead, when customer purchases a product, the store owner places the order with the original vendor and have them ship the item directly to the customer.

The main difference between a dropshipping business vs traditional eCommerce business is that dropshipping doesn’t require you to stock or own any inventory. You also don’t have to deal with any shipping or handling logistics.

When a product is sold through your online store, you simply forward the purchase order to a wholesaler or manufacturer who fulfills it.

Due to the low operating cost and easier setup, dropshipping has become a global eCommerce trend.

The dropshipping business model has a few pros and cons that you need to keep in mind before getting started.

Pros of starting a dropshipping store

  • Setting up a dropshipping business requires much lower investment than a typical online store
  • You don’t need to purchase products or manage an inventory
  • You don’t need to ship the product by yourself
  • You can sell variety of products from different vendors and manufacturers

Cons of starting a dropshipping store

  • You are not in control of product quality and availability
  • Managing customer expectations can be challenging when you don’t have control over quality or shipping of the products
  • Providing customer support can be challenging
  • You’ll be making less profit because instead of bulk buying products, you’ll be selling one item at a time

With that said, dropshipping is a proven way to make money online. You can use dropshipping to make extra money on the side or build a large profitable online business.

Let’s take a look at how to properly start a dropshipping business.

How to Start a Dropshipping Business

Starting a dropshipping business is not as difficult as you’d think. There are plenty of eCommerce platforms that allow you to easily set up a dropshipping store without any technical skills.

We recommend using WooCommerce because of its low setup costs, ability to use multiple payment gateways, and flexibility to customize your online store.

According to Builtwith, WooCommerce is the #1 software used to build eCommerce stores.

It is also the most popular choice among dropshipping stores mainly because it runs on top of WordPress, the popular website builder. Using WooCommerce gives you access to thousands of WordPress extensions, third-party integrations, and beautiful store designs.

What You’ll Need to Start Dropshipping with WooCommerce

WooCommerce is available as a free plugin for WordPress. You’ll need a self-hosted WordPress.org website to start your dropshipping store. For details, see our guide on the difference between WordPress.com vs WordPress.org.

To get started with WordPress and WooCommerce, you’ll need the following items:

  • A domain name (This will be your store’s online address e.g. wpbeginner.com)
  • Web hosting account (This is where your website’s files will be stored)
  • SSL certificate (You’ll need it to accept online payments)

Normally, a domain name costs $14.99 / year, SSL Certificate $69.99 / year, and web hosting starts from $7.99/month.

Now, this is not a small investment if you are just starting out.

Luckily, Bluehost, our hosting partner, has agreed to offer WPBeginner users a discount on hosting with free domain name + SSL certificate. Basically, you’d be able to get started for $2.75 per month.

→ Click Here to Claim This Exclusive Bluehost Offer ←

Bluehost is one of the largest hosting companies in the world, and they are an officially recommended hosting provider by both WordPress and WooCommerce.

Once you sign up, Bluehost will send your login details to your email address. It will also automatically install WordPress for you, so you can easily login to WordPress dashboard from your hosting control panel.

Login to WordPress

Next, you need to install and activate the WooCommerce plugin. See our guide on how to install a plugin in WordPress for detailed instructions.

Upon activation, you WooCommerce will show you a guided a set up to select currency and other basic settings.

For more detailed instructions, see our tutorial on how to start an online store.

Choosing a Design for Your Dropshipping Store

Choosing templates and design for your online store

The first thing you would want to do is to change the appearance of your dropshipping store. Luckily, one of the best thing about using WordPress is that you can select from thousands of WooCommerce themes.

Here are our top picks for a dropshipping WooCommerce theme.

  • Astra WooCommerce Theme – A powerful WooCommerce theme built specifically to boost sales and increase conversions.
  • Divi – Another highly customizable WooCommerce theme that comes with built-in drag & drop page builder support.
  • OceanWP – OceanWP is a multi-purpose WooCommerce ready theme with flexible customization options.
  • Ultra – A multi-purpose WordPress theme with several ready-made layouts and a built-in drag and drop page builder.

Once you have found a theme you like, follow our guide on how to install a WordPress theme for step by step instructions.

Finding Dropshipping Products to Sell on Your Website

Finding dropshipping products

The next step is to find the products you want to sell on your dropshipping store. Before you start picking products, first you need to decide what kind of products you want to sell.

We recommend choosing a niche for your store. This will make it easier for you to find products as well as customers.

For example: if you want to sell clothing and accessories, then you can narrow it down to by style, theme, or a target audience.

It’s generally a good idea to pick a niche that you are familiar with and passionate about. Making a store about products or topics that you are unfamiliar with will require a lot more effort.

After choosing a niche for your store, you can look for products in that particular category.

In your product research, you want to look for products with low competition and high demand.

To find out which products are trending, you can browse Amazon to collect data and do your own research. Amazon shows best selling, most wished for, and top rated products for many categories.

Product research on Amazon

You can also use keyword research to find which product categories people are actually searching for. See our guide on how to properly do keyword research for detailed instructions.

For more on this topic, see our detailed guide on how to find the best products to sell online.

Where to Find Dropshipping Suppliers and Vendors

Once you have decided what products you are going to sell on your store, the next step is to find dropshipping suppliers offering those products.

There are many online marketplaces where you can find dropshipping suppliers and vendors from all over the world. Here is a quick list of the best dropshipping marketplaces to look for suppliers.

  • AliExpress – It is the largest online marketplace of suppliers offering millions of products. You can easily integrate it into your WordPress site to import products directly from AliExpress website.
  • SaleHoo – A powerful online marketplace for dropshippers, suppliers, and eCommerce stores. It is a paid platform and subscription costs $67 per year.
  • Doba – A large marketplace to find dropshipping suppliers. It allows you to manage lists, find products, and connect with suppliers. Subscription starts from $29 per month
  • Etsy – Etsy is an eCommerce platform for unique and hand-made products. Many of these manufacturers would gladly dropship products directly to your customers.

We recommend starting with AliExpress for multiple reasons. First, there are easy to use WordPress plugins that will make it easy to import products directly from AliExpress to your store (and keep it in sync).

AliExpress also makes order fulfillment quite easy for eCommerce stores. As the largest marketplace for dropshipping suppliers, you can find reliable vendors with great ratings and reviews.

AliExpress

Along with dropshipping products, you can also sell third-party products for affiliate commission on your store. This would allow you to offer a large range of products while diversifying your income stream.

Amazon.com is the best source to find affiliate products. Your affiliate earnings will be lower, and you’ll not be able to set custom pricing. However, you can find unique products and use it to provide more shopping choices on your store.

For details see our guide on how to create an Amazon affiliate store with WooCommerce.

Adding Dropshipping Products to Your WooCommerce Store

By default, WooCommerce does not come with seamless dropshipping functionality. Luckily, there are several excellent WooCommerce dropshipping that allow you to do that.

Using a dropshipping extension, you’d be able to easily add dropshipping products, set custom prices with desired profit margin, collect orders, send them to your supplier, and more.

The functionality of your dropshipping extensions would entirely depend on the supplier or marketplace you choose.

If you are selling products from multiple suppliers from different marketplaces, then you may need multiple dropshipping extensions to automate the checkout process.

Here is our pick of the top dropshipping addons for WordPress.

  • AliDropship – Makes it easy to import from thousands of products on AliExpress, offer seamless checkout experience, and 1-click order fulfillment.
  • WooDropship – Another popular plugin that makes it easy to import products from AliExpress, automatically add product images and sync pricing.
  • WooCommerce Dropshipping – Allows you to add other third-party suppliers or vendors to your WooCommerce store, and send them order details in PDF format for fulfillment.

The way you add products to your WooCommerce store will depend on which extension, marketplace, or supplier you go with. If the extension you choose allows you to automatically import products, then you can just do that (hint: the first two in our list make it super easy to import products from AliExpress).

On the other hand, if you need to manually add products to your store, then here is how you would do it.

Manually Adding Dropshipping Products in WooCommerce

Adding products to your WooCommerce store is quite simple. First, you need to visit Products » Add New page inside your WordPress admin area.

Add new product in WooCommerce

Start by providing a product title and a detailed product description. After that, you need to select product category and start uploading product photo and product gallery images.

Choose product category and images

You can find product images from the supplier’s website. However, you need to ask their permission to use those images. They may also be able to provide you additional product images that you can use.

Next, you need to add product details under the Product data section. From here, you can set product price, attributes, and other options.

Add product data

Below that, you can provide a short description for the product. This short description will appear on the shop front, product category, and product search pages.

Go ahead and publish your product to make it appear live on your store.

Repeat the process to add more products.

Managing Dropshipping Orders in WooCommerce

After you have added products in your store, customers will be able to buy them from your website. You’d be able to review the customer orders by visiting WooCommerce » Orders page.

Managing dropshipping orders

Depending on your dropshipping extension, you may see an option to fulfill orders from here. This would basically send the customer’s order details to the supplier associated with the product.

WooCommerce plugins like AliDropship makes it super easy to send orders to the supplier with a single click.

If your extension does not support that feature, then you’ll need to manually place the order with your supplier by providing them the customer’s order details and shipping information.

You can review each order by clicking on it.

Change order details

On the order detail page, you can view products ordered, customer payment information, and edit the order status. Once the order is shipped by the supplier, you can change its status to completed.

Resources and Tools to Grow Your Dropshipping Business

Resources and tools to grow your dropshipping business

Setting up a dropshipping store with WooCommerce is quite easy. However, the real work starts once your store is up and running.

You would need to promote your business, bring traffic to your website, convert traffic into customers, and keep improving your marketing strategy over time.

Luckily, there are tons of great tools and extensions that you can use to help you achieve these goals. Let’s start with the basics first.

1. Ecommerce SEO

SEO or Search Engine Optimization helps you to get more traffic from search engines to your store. You can follow the instructions in our complete WooCommerce SEO guide to get more visitors to your website.

2. Optimize Conversions

Once you have a steady stream of visitors, you would want them to make a purchase. In marketing terms, this is called a conversion (converting a visitor into performing a desired action).

Conversion optimization helps you boost sales, which makes it incredibly important for your online success.

We recommend using OptinMonster, the #1 conversion optimization toolkit on the web. We have a detailed WooCommerce conversion optimization guide that helps you learn how to do that using the latest techniques.

3. Recover Abandoned Carts

Using conversion and SEO, you would be able to bring visitors to your site and help them discover more products. However, a lot of those visitors may not complete a purchase.

They may leave create an account, add products to the cart, but leave before purchasing. You’ll need to learn how to bring back those customers and recover your abandoned cart sales.

4. Ecommerce Analytics

Obviously, you would want to see how all your efforts are paying off. For this, you’ll need MonsterInsights, which helps you install Google Analytics and comes with enhanced eCommerce tracking feature.

Using MonsterInsights you can track WooCommerce customers, see which products are popular, which product pages are not performing so well, and more.

5. Misc. Plugins

WooCommerce gives you access to more than 55,000+ WordPress plugins and many of them are made specifically for eCommerce websites.

These plugins allow you to add features like contact forms, product comparisons, currency switchers, and more. See our list of the best WooCommerce plugins to find more plugins for your store.

FAQs about Dropshipping with WordPress

You may come across new questions as you start working on your new dropshipping store. Following are the answers to some of the most commonly asked questions about dropshipping with WooCommerce.

1. Why not start my dropshipping business with Shopify?

You can totally start your dropshipping business with Shopify. However, Shopify charges you for each transaction, which affects your profits as a dropshipping store.

Another downside of using Shopify is the limited number of extensions and apps that you can use. As a dropshipping business, WooCommerce gives you more extensions and the flexibility to sell whatever you want on your website.

See our comparison of Shopify vs WooCommerce for more information.

2. Can I start my dropshipping business with BigCommerce?

Yes, you can. BigCommerce is a popular eCommerce platform and it even integrates with WordPress. BigCommerce also offers more payment gateways, and it does not charge transaction fees.

It lacks in extensions and the flexibility of WooCommerce, but it offers better scalability. See our comparison of WooCommerce vs BigCommerce for more details.

3. Which hosting company to choose for my WooCommerce store?

We recommend using Bluehost for a new dropshipping business. Their shared hosting plan is perfect to get started, and they are an officially recommended WooCommerce hosting provider.

If you are looking for an alternative, then we would recommend SiteGround. They are well-known for their heroic support and fast servers.

If you can spend a little more, then you can go WP Engine. They are a managed WordPress hosting provider, which is like a concierge service for your eCommerce store.

4. Can I install WooCommerce on my existing WordPress site?

Yes, you can. WooCommerce is available as a WordPress plugin and you can install it on any WordPress site.

5. How do I make sure that dropshipping suppliers deliver products on time?

Most dropshipping suppliers are located in China. This means slower delivery than choosing a vendors located in your own country. However, many dropshipping suppliers use ePacket for faster deliveries.

ePacket is basically a faster shipping method used by suppliers in China in partnership with USPS and other mail services. Ask your suppliers if they deliver products via ePacket for faster deliveries.

6. What to look for when finding a dropshipping supplier?

AliExpress and other marketplaces allow you to view supplier ratings, reviews, number of products they have delivered, and other useful information. This data tells you how reliable a supplier has been in the past. You can also read reviews to learn more about the quality of products delivered.

Since you don’t have control over the quality and delivery of products, you need to spend time on finding reliable dropshipping partners for your store.

7. Is dropshipping legal?

Because starting a dropshipping business is extremely easy, many beginners wonder if dropshipping is legal. The answer is YES. It is completely legal across the world.

In the simplest terms, dropshipping is just a form of order fulfillment where the supplier or manufacturer handles shipping. Nothing is illegal about that.

Of course like any other business, you have to pay proper business taxes depending on the country you’re based in.

We hope this guide helped you learn how to start dropshipping business with WordPress. You may also want to see our guide on how to add live chat support to your WooCommerce store.

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.



Source link

Categories
Website

A Step by Step Guide (2019)

Did you know that WordPress comes with a built-in feature that allows you to undo changes and go back to a previous version of a post?

This feature is called Post Revisions or simply Revisions.

Most of us make mistakes when writing. Sometimes you might wish that you hadn’t deleted what you wrote earlier. Revisions allow you to fix that by going back in time and undoing the changes.

In this article, we will show you how to easily undo changes in WordPress with post revisions. We will also show you how to easily manage post revisions in WordPress.

Managing the WordPress post revisions

Here is an overview of the topics we’ll cover in this guide:

What is Post Revisions?

Post revisions is a WordPress feature that allows you to undo changes and go back to an earlier version of your posts and pages.

For each draft you are working on, WordPress automatically saves a temporary revision. This type of revision is called auto-save.

WordPress stores an auto-save every 60 seconds. It also automatically replaces the older version with the new auto-save.

Autosave revisions in WordPress

The autosave feature helps you restore the content if something goes wrong before you can save it. For example, if your browser crashed or your computer hanged while writing, then you can restore your latest draft from the autosave.

WordPress also saves post revisions each time a user clicks on the save, update, or publish button. Unlike auto-saves, these revisions are permanently stored in the WordPress database.

You can locate, browse, and revert back to any of these revisions from the post edit screen.

Why You Should Use Post Revisions

Almost every WordPress user can benefit from post revisions. Writing great content requires a lot of tweaking and edits. Post revisions allow you to see your process and take a bird’s eye view of how your post has evolved.

You can then switch between different states of your draft, make changes, and make your article perfect for publishing.

For multi-author WordPress sites, post revisions allow editors to easily manage the work of multiple authors. You can see who made changes to an article, what changes they made, and so on.

That being said, let’s take a look at how to use post revisions to improve your WordPress posts and pages.

How to use Post Revisions to Undo Changes in WordPress

WordPress displays the number of revisions under the ‘Document’ panel on the post/page edit screen.

You can find that on the right-hand side of your post editor screen. Clicking on the ‘Revisions’ will take you to post revisions screen.

Post revisions in WordPress

The post revision screen will show you the latest revision of the post with a scrollbar on top. Sliding the button on the scroll bar will take you to earlier revisions of the post.

Switching between post revisions

Changes made in each revision will be highlighted in green and pink colors. On the top, you can see the user who made these changes, time, and other information.

WordPress will also let you know if a revision is an autosave or a draft.

Restore autosaves aswell as revisions

You can use the next and previous buttons to move around revisions.

Plus, you can check the box on top that says ‘Compare any two revisions’. Doing so will split the scrollbar button into two, and you can take each button to a different revision and compare the difference between two distant revisions.

Compare any two revisions

To restore a revision, you can simply click on Restore This Revision or Restore This Autosave button.

WordPress will restore the selected revision as your current post revision, and you can then save it as a draft.

Restore revision point

Keep in my mind that restoring to an earlier revision will not delete the latest version of your post. Instead, WordPress will store it in the database as another revision.

Using post revisions with Classic WordPress editor

In case you haven’t upgraded your WordPress to Gutenberg and still using the Classic Editor, then you’ll find the post revisions in the publish meta box on the right panel of the post/page edit screen.

Browsing post revisions in classic editor

To view the post revisions, you can simply click the ‘Browse’ link next to the number of revisions. Apart from this, the post revisions work similarly in both the Classic Editor and Gutenberg.

Limiting Post Revisions in WordPress

All post revisions are stored in your WordPress database. Due to this, many users worry that too many revisions can slow down their websites.

It is not true.

WordPress skips post revisions when making database calls on the front end. It only looks for revisions on the post edit screen, or when you are actually browsing revisions.

You can still control and limit post revisions in WordPress. We’ll show you two different methods to do that you can choose one that best suits you.

1. Limit post revisions in WordPress using plugin

The easiest way to manage WordPress post revisions is by using a plugin. This allows you to control revisions from the WordPress admin area.

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

Upon activation, you need to visit Settings » Writing page and scroll down to WP Revisions Control section.

WP Revisions Control settings

From here you need to enter the number of revisions you want to store for each post type and then click on the ‘Save Changes’ button to store your settings.

WP Revisions Control will now limit the post revisions stored in your WordPress database.

The plugin also allows you to delete revisions for an individual post. Simply edit the post where you want to delete revisions and scroll down below the editor.

Purge revisions

You can limit the revisions for this post only or delete them by clicking on the ‘Purge these revisions’ button.

2. Limit WordPress post revisions manually

WordPress allows you to control how many revisions you want to keep for an article. To limit post revisions, simply add this code to your WordPress site’s wp-config.php file.

define( 'WP_POST_REVISIONS', 10 );

Don’t forget to replace 10 with the number of revisions you want to keep for each post.

How to Delete Old Post Revisions in WordPress

Old post revisions are perfectly harmless, and you don’t need to delete them in most cases. However, if you have a very large website with thousands of articles, then deleting old post revisions can help you reduce backup sizes.

First, you’ll need to install and activate the WP-Optimize plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, go to WP-Optimize » Database page and check the box next to ‘Clean all post revisions’ option.

Clean post revisions

Now click on the ‘Run optimization’ button to delete all post revisions. You can uninstall the plugin after you have deleted the revisions.

Once you have cleaned up revisions, feel free to uninstall and delete the plugin.

Deleting WordPress post revisions via phpMyAdmin

Advanced users can also delete WordPress posts revisions via phpMyAdmin.

First, make sure that you have created a complete WordPress database backup.

After that, simply login to your WordPress hosting control panel and click on the phpMyAdmin icon.

Next, you need to select your WordPress database from the left column. PhpMyAdmin will now display tables in your WordPress database.

PhpMyAdmin

After that, you need to click on the SQL tab from the top menu.

This will load phpMyAdmin’s SQL interface. From here you can manually run commands on your WordPress database.

You need to enter the following code.

DELETE FROM wp_posts WHERE post_type = "revision";

Don’t forget to replace wp_ with your own WordPress database prefix. After that, click on the Go button to run the command.

Deleting revision via MySQL

PhpMyAdmin will now delete all revisions from your WordPress database.

Note: Deleting revisions will not stop WordPress from saving revisions for your future posts.

How to Completely Disable WordPress Post Revisions

We don’t recommend disabling WordPress post revisions. However, some users may want to disable revisions to reduce their WordPress database size.

The easiest way to do this is by installing Disable Post Revision plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, go to Settings » Writing page and select the post types where you want to disable revisions feature.

Disable revision plugin

Don’t forget to click on the save changes button to store your settings.

If you don’t want to use the plugin, then you can also do the same thing manually by adding this code to your wp-config.php file.

define('WP_POST_REVISIONS', false );

This code disables WordPress post revisions feature on your website. It will still allow WordPress to save one autosave and one revision in your browser storage.

We hope this article helped you learn how to use WordPress post revisions to undo changes and how to manage post revisions for larger sites. You may also want to see our beginners guide on managing your editorial workflow in WordPress.

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.



Source link