The Form Builder icon picker (Icon Type → Icon → Choose icon) comes with the Classified Listing icon set. You can add your own icon pack to it, for example an icon font made with IcoMoon or Fontello, so your icons appear in the Icon Library next to the built-in ones and can be used on fields, field options and directories.
This guide walks you through it step by step. You only need basic PHP and CSS, and about 15 minutes.
How it works #
Two things have to happen for a custom icon to work:
- The picker has to know the icon’s CSS class. The list of icons in the picker comes from the
rtcl_get_icon_class_listfilter. You add your class names to that list. - The browser has to load your icon CSS. The picker and your forms simply print
<i class="your-icon-class"></i>. If your icon stylesheet is not loaded on that page, the icon shows up as an empty box.
So we will: (1) put the icon font files in a small plugin, (2) load the CSS in the admin and on the front end, and (3) add the class names to the filter.
What you need #
- An icon font with a CSS file in which every icon has its own class, for example
myicon-truck,myicon-bike. - FTP or file manager access to
wp-content/plugins/. - Classified Listing active, with the Form Builder enabled.
Tip: Use a class prefix that nobody else uses, such as
myicon-or your company name. Avoidrtcl-icon-andfa-, which are already used by Classified Listing and Font Awesome.
Step 1: Create a small plugin for your icons #
Keep your icons in their own plugin, not inside the Classified Listing folder. Plugin updates replace the Classified Listing folder, but your own plugin stays untouched. (A child theme’s functions.php also works, but a plugin keeps working if you change the theme.)
Create this folder structure:
wp-content/plugins/my-rtcl-icons/
├── my-rtcl-icons.php
└── assets/
├── my-icons.css
└── fonts/
├── my-icons.woff2
└── my-icons.woff
Copy the font files from your icon pack into assets/fonts/, and its stylesheet into assets/my-icons.css.
Step 2: Check the icon CSS #
Open assets/my-icons.css. It should look roughly like the example below. The two things to check are:
- The
url(...)paths point to thefonts/folder relative to the CSS file. - There is one class per icon (
.myicon-truck::beforeand so on).
@font-face {
font-family: "my-icons";
src: url("fonts/my-icons.woff2") format("woff2"),
url("fonts/my-icons.woff") format("woff");
font-weight: normal;
font-style: normal;
font-display: block;
}
/* Shared style for every icon whose class starts with "myicon-". */
[class^="myicon-"],
[class*=" myicon-"] {
font-family: "my-icons" !important;
font-style: normal;
font-weight: normal;
line-height: 1;
speak: never;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
/* One rule per icon. The "content" codes come from your icon pack. */
.myicon-truck::before { content: "\e900"; }
.myicon-bike::before { content: "\e901"; }
.myicon-house::before { content: "\e902"; }
Using SVG icons instead of a font? That works too, as long as each icon is a CSS class, for example a class that sets
background-imageormask-imageto your SVG and gives the element a width and height. The picker only cares about the class name.
Step 3: Write the plugin file #
Paste the code below into my-rtcl-icons.php. Then replace the class names in my_rtcl_icon_classes() with the ones from your CSS file.
<?php
/**
* Plugin Name: My Classified Listing Icons
* Description: Adds my own icon pack to the Classified Listing Form Builder icon picker.
* Version: 1.0.0
* Requires Plugins: classified-listing
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Stop if this file is opened directly.
}
/**
* The CSS classes of my icons, exactly as they are written in my-icons.css
* (without the leading dot).
*
* @return string[]
*/
function my_rtcl_icon_classes() {
return [
'myicon-truck',
'myicon-bike',
'myicon-house',
];
}
/**
* 1. Add my icons to the Form Builder icon picker.
*
* The filter receives the built-in icon list; we return it with our icons added.
*/
add_filter( 'rtcl_get_icon_class_list', function ( $icons ) {
return array_merge( my_rtcl_icon_classes(), $icons );
} );
/**
* Register the icon stylesheet once, for both the admin and the front end.
*/
function my_rtcl_register_icon_css() {
wp_register_style(
'my-rtcl-icons',
plugin_dir_url( __FILE__ ) . 'assets/my-icons.css',
[],
'1.0.0' // Change this number whenever you update the icons, to clear browser caches.
);
}
/**
* 2. Load the icons in the admin: the Form Builder screen and the listing add / edit screens.
*/
add_action( 'admin_enqueue_scripts', function ( $hook ) {
my_rtcl_register_icon_css();
$screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
$is_form_builder = (bool) preg_match( '/_page_rtcl-fb$/', $hook );
$is_listing_page = $screen && 'rtcl_listing' === $screen->post_type;
if ( $is_form_builder || $is_listing_page ) {
wp_enqueue_style( 'my-rtcl-icons' );
}
} );
/**
* 3. Load the icons on the front end, where the submit form, listings and
* directory list show them.
*/
add_action( 'wp_enqueue_scripts', function () {
my_rtcl_register_icon_css();
wp_enqueue_style( 'my-rtcl-icons' );
} );
What each part does:
| Part | What it does |
|---|---|
my_rtcl_icon_classes() | The one place where you list your icon classes. Add a line here for every new icon. |
rtcl_get_icon_class_list filter | Adds your classes to the list the picker shows. array_merge( mine, $icons ) puts your icons first; swap the two arguments to put them last. |
admin_enqueue_scripts | Loads your CSS on the Form Builder screen (so the picker can draw the icons) and on the admin Add / Edit Listing screen (so the form there shows them). |
wp_enqueue_scripts | Loads your CSS on the front end, so visitors see the icons in the listing submit form and wherever the chosen icon is displayed. |
Step 4: Activate and test #
- Go to Plugins and activate My Classified Listing Icons.
- Open Classified Listing → Form Builder and edit a form.
- Click a field, then in Input Customization set Icon Type to Icon.
- Click Choose icon. The Icon Library opens. Type your prefix (for example
myicon) in the search box: your icons appear. - Click your icon, then Insert (or double-click the icon). Click Save Form.
- Open the listing submit page on the front end and check that the icon shows next to the field.
The name under each icon in the library comes from its class:
myicon-truckis shown as “Myicon Truck”. Search also matches the class name, so searchingtruckormyiconboth find it.
Optional: show only your own icons #
If you want the picker to show only your icon pack and hide the built-in icons, return your list instead of merging it:
add_filter( 'rtcl_get_icon_class_list', function ( $icons ) {
return my_rtcl_icon_classes();
} );
Careful: fields that already use a built-in icon keep that icon on the front end, but you can no longer pick it again in the builder. Only do this on a new site, or after you have changed those fields.
Optional: icons that need two classes #
Some icon packs need two classes per icon, for example Font Awesome 6 uses fa-solid fa-truck. Add the full class string as one item, with a space in between:
function my_rtcl_icon_classes() {
return [
'fa-solid fa-truck',
'fa-solid fa-motorcycle',
];
}
Remember that the pack’s own CSS (here the Font Awesome stylesheet) must be loaded by your plugin as in Step 3. Classified Listing does not load Font Awesome on every page.
Troubleshooting #
| Problem | Cause and fix |
|---|---|
| My icons don’t appear in the Icon Library at all. | The filter is not running. Check that the plugin is active and that there is no PHP error (turn on WP_DEBUG). Then reload the Form Builder page with a hard refresh (Ctrl/Cmd + Shift + R). |
| The tiles appear with the right names, but the icons are empty boxes. | The CSS is not loaded, or its font paths are wrong. Open the browser DevTools → Network tab, reload, and look for my-icons.css and the .woff2 file. A 404 means the path in wp_register_style() or in the CSS url(...) is wrong. |
| Icons work in the builder but not on the front end. | The wp_enqueue_scripts part is missing, or a caching / optimisation plugin is serving an old CSS bundle. Clear its cache. |
| Some icons look like a different icon or a square. | The content code in your CSS does not match the font. Re-export the CSS from your icon tool together with the font files. |
| After updating the icon pack, the old icons still show. | Browsers cache fonts. Increase the version number in wp_register_style() (for example 1.0.1). |
Summary #
- Put your icon font and CSS in your own small plugin.
- Add your classes with the
rtcl_get_icon_class_listfilter. - Load your CSS on the Form Builder screen, the admin listing screens and the front end.
- Pick your icon in the Icon Library, insert it, and save the form.