Instead of redefining wp_star_rating()
for the front end, you should be able to just use the built-in function.
From the Codex page for wp_star_rating()
:
In order to use this function on the front end, your template must include the
wp-admin/includes/template.php
file and enqueue the appropriate dashicons CSS font information.
(emphasis mine)
A code sample is also provided in the Notes section of the Codex page.
Edit
If you’re getting Fatal error: Call to undefined function wp_star_rating()
messages, that means that you have not included wp-admin/includes/template.php
in your file. Try adding this snippet somewhere prior to your call to wp_star_rating()
:
require_once( ABSPATH . 'wp-admin/includes/template.php' );
That should allow you to use wp_star_rating()
in your front-end code.
Related Posts:
- get_template_directory_uri pointing to parent theme not child theme
- Include PHP file in Content using [shortcode]
- Php string not working in WordPress Functions.php (trying to fetch 1st category for each blog that post appears in the sidebar)
- Adding extra SVGs to TwentyNineteen child theme using class TwentyNineteen_SVG_Icons
- What is the most efficient method for loading widgets in functions.php
- Where does function_exists() look to decide whether a function exists? [closed]
- Twenty Eleven Child theme error when attempting to use a rewritten function
- PHP files included in functions.php don’t seem to work
- Change Rating range in Link Manager
- Include files in child themes, declare in functions.php
- using `require` in my functions.php breaks the site
- Override a theme function in a child theme?
- Calling a Function in Functions.php from an external PHP script
- Automatically include all php files in a child theme directory
- Impossible to call wordpress function inside an include?
- Can I have an additional functions.php file in WordPress?
- Check from functions.php if function exists in footer.php
- Unable to point the child theme directory even using get_stylesheet_directory()
- Can I include a custom PHP function in a WordPress function?
- file.php not loaded?
- Why should I use get_template_directory() when include files?
- WordPress functions.php conditional include another functions file
- I have an fatal error on my funcyions.php
- Including admin-options.php file in Child Themes
- Providing fallback function and allow override by plugin
- Retrieve array of attachment IDs attached to a given Post ID
- Undo a function that is not (seemingly) hooked to an action?
- plugins_url vs plugin_dir_url
- Get list of years when posts have been published
- Is it possible to remove the “standard” post format?
- Do WordPress’ cron’s clean up expired transients?
- How to add first name & last name to default registration form?
- Masking logout URL
- How can I programmatically create “child” pages on theme activation?
- Warning/Notice about functions.php
- Is checking whether the blog is installed necessary?
- Replace Archive Widget Link Text
- How do I deactivate a plugin for some roles
- How to display more audio file ID3 tags in WordPress
- Searching for content post
- Running CRON on Server with WP Function
- Using separate .php file for functions – how to run on site?
- How to add custom fields to my custom registration form
- Add Featured image column into wordpress admin on pages AND posts
- How can I change the do_action function in footer (copyright area)
- How to display post content instead of excerpt
- Access Plugin data from Functions.php
- Having a Function Inside of the Loop
- how to call a function only in specific pages and exclude it from other pages
- Which action does wp_update_user triggers?
- Use register_setting() in a loop
- Dynamic dropdown from database table
- Add dynamic links in WordPress custom theme
- WordPress website Rs changed to currency symbol
- Functions in custom theme
- Attempt to change jQuery version caused White Screen of Death
- check if author has published posts in custom post type, then send mail
- media resize/crop possibilities?
- paginate_links() don’t properly work in search.php?
- Difference b/w Simple function call & do_action call
- What’s wrong with my use of plugin_url()?
- Hook into a function without a hook?
- Filter yoast canonical add_action priority [closed]
- Should I store functions in separate folder?
- How can I modify the element on all pages?
- AMP – Change rel=”canonical” from functions.php [closed]
- Dropline menus — seperators between children only?
- Echoing function into WordPress NextGen gallery
- get_post_meta() problem again
- does wp function the_content(); accept another tag inside
- How to parse a shortcode within a shortcode?
- Variables not showing in short code
- Prevent loading of functions
- Get term slug by term id and then explode it
- Shortcode question
- call_user_func_array() expects parameter 1 to be a valid callback, function
- the_widget() inside functions.php
- loginout function customization
- define css class in functions.php
- Adding tables to the WordPress Editor
- Add Login and logout buttons to top menu bar
- implementing a centralized content “show-do-not-show” toggle?
- How to load a css file depending on the current role
- How to add HTML into error message
- Add a word after the post url if it is within a specific category
- Probleme shortcode with list author
- Security when outputing wp_oembed_get code
- Function for Sticky Post on Categories causes issues with 404 behavior
- Unable to declare AOS library in functions
- Get value of pre-populated Gravity forms field as variable in my function
- Will dequeueing in child theme functions.php file prevent Google Fonts from loading?
- Graphic before title – Specific Category
- Edit meta fields from within template
- What to do to have access to WordPress functions
- Adding a meta box fields to child theme options page
- Changing the color of post title [closed]
- How to programmatically GET (to know) which Sidebar (or) which Menu is being used on Different Pages?
- Remove theme, change theme button and WP version on “Right Now” admin dashboard?
- Making an under maintenance page (without using plugins)
- WPDB query suddenly not working