Skip to main content

Add AnnounceKit to WordPress

WordPress is a flexible platform for any kind of website, from blogs to online stores. You can add AnnounceKit widgets to a WordPress site with the same script snippet you use anywhere else; no AnnounceKit plugin is needed.

Step 1. Copy your widget code

Open Engage > Widgets in the AnnounceKit dashboard, choose a widget (or create one) and copy its install code.

Step 2. Add a place for the badge (Badge and Line widgets)

Badge and Line widgets need an element on the page to sit in. The install code targets the class announcekit-widget. For a menu item:

  1. Go to WP Admin > Appearance > Menus.
  2. Click Screen Options at the top of the screen and tick CSS Classes.
  3. Add a menu item (for example a Custom Link labelled “What’s new”) and set announcekit-widget in its CSS Classes field.

You can also put <div class="announcekit-widget"></div> in any HTML block or theme template. Float, Drawer and Embed widgets and the JavaScript type do not need this step (an Embed widget needs the element where its content should appear).

Step 3. Add the code to every page

Paste the install code right above the </body> tag of your site. You can do this in one of two ways:

  • With a header and footer code plugin from the WordPress plugin directory: paste the code in its footer (or “body end”) box.
  • In your theme: add the code to the theme’s footer.php (preferably in a child theme, so theme updates do not remove it).

Step 4. Check your site

Reload your site: the badge appears next to the menu item (or the widget appears where you placed it). To pass your WordPress users to AnnounceKit for user tracking and segmentation, add the user and data options to the code as described in the Widget setup.

Troubleshoot

Can I change the position of the widget?

Yes. Pass a style object in the install code to fine-tune the launcher’s position; see Styling.

Widget doesn’t appear on the menu

Make sure the menu item has the announcekit-widget class (Step 2) and that the selector in your install code is .announcekit-widget. Some themes render the menu twice (desktop and mobile); the badge attaches to the first match.

Only Badge and Line widget types attach to a menu item. Make sure you copied the code of the right widget.

If you still have problems, do not hesitate to contact us.