Hello,
wpDiscuz loads an extra font called square721_cn to display the rating count just above the comments.
/wp-content/plugins/wpdiscuz/themes/default/css/fonts/sqr721c-webfont.woff2
Is there any way to disable this font so that it uses the default font I'm using on my site? The extra requests generated by this font are something I would like to avoid if possible.
This is not an extra font. It's used for displaying the article rating. We're really sorry, but this font cannot be removed.
I'm also concerned by this. Is there a way to inject an SVG or an icon from a font file. I tried targeting the SVG element of the star and then adding these parameters:
- font-family: myfonts!important;
- font-style: normal;
- content: "\f16a";
This usually works. I do it to load Elementor icons from my custom files, but it didn't work.
And in general I think you should just fix this. 18kb for a simple star is not reasonable in this day and age, regarding google CWV.
I used this code and it worked:
function my_custom_wpdiscuz_full_star_svg($svg, $type, $icon) { // Only modify the SVG for post ratings if ($type === "post") { // Set the URL of your custom SVG file $custom_svg_url = '*url*/star-full.svg'; // Replace with your actual SVG URL // Get the contents of your custom SVG file using the URL $custom_svg = file_get_contents($custom_svg_url); // Directly return the custom SVG without string manipulation return $custom_svg; } return $svg; } add_filter('wpdiscuz_full_star_svg', 'my_custom_wpdiscuz_full_star_svg', 10, 3); function my_custom_wpdiscuz_half_star_svg($svg, $type, $icon) { // Only modify the SVG for post ratings (assuming filter exclusivity) if ($type === "post") { // Set the URL of your custom half-star SVG file $custom_half_star_url = '*url*/half-star.svg'; // Replace with your actual SVG URL // Get the contents of the custom SVG file using the URL $custom_svg = file_get_contents($custom_half_star_url); // Directly return the custom SVG without string manipulation return $custom_svg; } return $svg; // Return the original SVG for other types } add_filter('wpdiscuz_half_star_svg', 'my_custom_wpdiscuz_half_star_svg', 10, 3);
I can see in the chrome's Dev Tools - that the star is loaded from the custom svg.
But the problem is that the custom
sqr721c-webfont.woff2
Still loads. I tried unloading it using this code:
function my_deregister_fonts() { wp_dequeue_style('wpdiscuz-font-sqr721c'); // Adjust the handle if needed } add_action('wp_enqueue_scripts', 'my_deregister_fonts', 11); // Priority 11 ensures it runs after wpDiscuz
But it didn't work. I also tried preventing the load using CSS:
/* Override font-face rule with specificity and !important */ body .wpdiscuz @font-face { /* Target the @font-face within wpdiscuz context */ font-family: 'square721_cn_btroman'; src: url('') !important; /* Empty URL and !important to prevent loading */ }
But again - it didn't work.
I'd appreciate your help!