Skip to content

How to create a contact information widget in WordPress?

WordPress offers many opportunities to customize your website according to your needs. One of them is the ability to add different types of widgets. Today we'll discuss how to create a contact information widget that will help your customers contact you quickly and easily.

Using the plugin to create a contact widget

The simplest solution for people who don't want to deal with coding is to use an appropriate plugin. There are many options on the market, but one of the most popular is “Contact Widgets”.

The steps to create a widget using “Contact Widgets” are as follows:

  1. Log in to the WordPress administration panel.
  2. Go to “Plugins” -> “Add New”.
  3. Type “Contact Widgets” in the search box and click “Install Now” and then “Activate.”
  4. After activating the plugin, go to “Appearance” -> “Widgets”.
  5. Find “Contact Widget” and drag it to the desired section.

Now you can start filling in your contact information such as address, phone number, email, etc.

Creating your own widget using PHP

If you have programming experience and prefer to control every detail of your website, you can create your own contact information widget using PHP. Here is the basic code you can use:

class Contact_Info_Widget extends WP_Widget { function __construct() { parent::__construct( 'contact_info_widget', __('Contact info', 'cinfo_domain'), array('description' => __( 'Contact info widget', 'cinfo_domain' )) ); } public function widget($args, $instance) { echo $args['before_widget']; echo $args['before_title']; echo $instance['title']; echo $args['after_title']; echo '
    '; echo '
  • ' . $instance['address'] . '
  • '; echo '
  • ' . $instance['phone'] . '
  • '; echo '
  • ' . $instance['email'] . '
  • '; echo '
'; echo $args['after_widget']; } // backend public function form($instance) { // configuration form in the backend } // updating widget public function update($new_instance, $old_instance) { // widget updating process } } function cinfo_load_widget() { register_widget('Contact_Info_Widget'); } add_action('widgets_init', 'cinfo_load_widget');

Remember that you need to implement the methods form() and update()so that you can configure and update the widget from the WordPress admin panel.

Using HTML and CSS in Text/HTML widgets

If you are not familiar with PHP but know the basics of HTML and CSS, this is the option for you. You can create a contact information widget using the Text/HTML widget:

  1. Log in to the WordPress administration panel.
  2. Go to “Appearance” -> “Widgets”.
  3. Drag the “Text” or “Custom HTML” widget to the desired section.
  4. Fill out the title and content fields with your contact information.
  5. Click “Save”.

Remember that you can format your contact information with HTML and style it with CSS.

To summarize, there are many ways to create a contact information widget in WordPress, depending on your experience level and preferences. Each of the above solutions offers different possibilities that allow you to adapt the widget to your needs.

Check out the offer of 1500+ Premium WordPress plugins and themes!