1. AAWP
  2. Documentation
  3. Extending & Styling
  4. Star Ratings: Replace icons

Basics

The basic structure of star ratings looks as follows:

  • 1 icon for the gray (inactive) background
  • 1 icon for the yellow (active) foreground

For a 4-star product rating, 4 active and 1 inactive star will be shown.

Icon sources

On the one hand you can create your own icons with almost every picture editing tool. On the other hand you can make use of a public resource like Iconfinder. Anyway the file format should be SVG, alternatively PNG or GIF. After getting your icons, please upload them on your server (e.g. via WordPress media).

Default sizes

On the plugin settings page (or via shortcode) you can choose between the following star rating sizes:

  • Small = 16px * 16px
  • Medium = 20px * 20px
  • Large = 30px * 30px

Please be aware that the new icons should be at least 30px * 30px in order to fit all sizes.

Replacing icons via CSS

On the plugin settings page (tab “output”) please select “Custom style” under the star ratings section. Afterwards you can replace the graphics easily as follows:

Variant 1: Replacing both icons

1
2
3
4
5
6
7
8
9
10
11
.aawp .aawp-star-rating--custom,
.aawp-star-rating--custom,
a.aawp-star-rating--custom {
    background-image: url('https://domain.de/path-to-images/star.png');
}

.aawp .aawp-star-rating--custom > span,
.aawp-star-rating--custom > span,
a.aawp-star-rating--custom > span {
    background-image: url('https://domain.de/path-to-images/star-active.png');
}

Variant 2: Replacing both icons and defining a custom size

This example sets a custom size of 32px * 16px for a horizontal icon.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
.aawp .aawp-star-rating--custom,
.aawp-star-rating--custom,
a.aawp-star-rating--custom {
    height: 16px;
    width: 32px;

    background-size: 32px 16px;
    background-image: url('https://domain.de/path-to-images/star.png');
}

.aawp .aawp-star-rating--custom > span,
.aawp-star-rating--custom > span,
a.aawp-star-rating--custom > span {
    height: 16px;
    width: 32px;

    background-size: 32px 16px;
    background-image: url('https://domain.de/path-to-images/star-active.png');
}

Variant 3: Eliminating the background icon

This example eliminates the inactive background icon.

1
2
3
4
5
6
7
8
9
10
11
.aawp .aawp-star-rating--custom,
.aawp-star-rating--custom,
a.aawp-star-rating--custom {
    background-image: none;
}

.aawp .aawp-star-rating--custom > span,
.aawp-star-rating--custom > span,
a.aawp-star-rating--custom > span {
    background-image: url('https://domain.de/path-to-images/star-active.png');
}

All previously showed styles should be placed into the settings field “Custom CSS” (tab “output”). Alternatively you can place them into your child-/theme’s styles. Therefore please put .aawp-custom in front of every declaration: e.g. .aawp-custom .aawp .aawp-star-rating--custom { ... }

Was this article helpful?

Related Articles