Title: Replace the print reviews function in theme
Last modified: August 30, 2016

---

# Replace the print reviews function in theme

 *  Resolved [John McCarthy](https://wordpress.org/support/users/john-lion/)
 * (@john-lion)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/replace-the-print-reviews-function-in-theme/)
 * Hi Nate,
 * I’m adding the `grfwp_print_reviews` function in my theme’s function.php file.
   I’m receiving the “cannot re-declare’ error.
 * To my knowledge as the function in the plugin is wrapped in `if ( !function_exists())`
   my function should be the one called.
 * Can you advise, ie see where I may be going wrong?
 * Note
    —-
 * Have tested with a clean install of WooThemes Storefront.
 * Thanks in advance
 * [https://wordpress.org/plugins/good-reviews-wp/](https://wordpress.org/plugins/good-reviews-wp/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [NateWr](https://wordpress.org/support/users/natewr/)
 * (@natewr)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/replace-the-print-reviews-function-in-theme/#post-6902327)
 * Hi John,
 * Although the function is technically “pluggable”, it’s defined early before the
   theme is loaded. The plugin should probably hook these functions in during the`
   init` hook instead.
 * Ideally, I’ll get a proper template in place for the review output so you can
   just drop a template file into your theme. But this plugin’s been a bit on the
   backburner while I focus on other plugins in my pack (not forgotten, just not
   a lot of active feature development).
 * In the meantime, you can use a [filter](https://github.com/NateWr/good-reviews-wp/blob/master/includes/template-functions.php#L43)
   to override the output and do effectively the same thing as your function override.
   If you need some help figuring out how to use that filter let me know.
 *  Thread Starter [John McCarthy](https://wordpress.org/support/users/john-lion/)
 * (@john-lion)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/replace-the-print-reviews-function-in-theme/#post-6902482)
 * Hi Nate,
 * Thanks for this, I understand, again the plugin is great. If I could help I would
   but I feel my developer skills are still a bit under par to do so.
 * None the less, I do plan to use the plugin for my clients and personal projects
   and therefore see myself customising at least the output and style quite a bit.
   If there is anything I can foresee my assistance being beneficial, I’ll give 
   you a shout 🙂
 * As for using the filter; hopefully I’ve got this right. I’d call the filter on
   my function with a value of true and ensure that I return $output. I would essentially
   just copy the original template and re-order elements.
 * When the check `if ( $output !== false ) {` returns true it returns my function
   rather than carrying on within the original template function to return the original
   output.
 * It’s taken me some time to wrap my head around filters, I haven’t fully mastered
   all scenarios. Any guidance would be appreciated.
 * Cheers
 *  [NateWr](https://wordpress.org/support/users/natewr/)
 * (@natewr)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/replace-the-print-reviews-function-in-theme/#post-6902483)
 * Hi John,
 * Here’s an example filter and function that overwrites the HTML output:
 *     ```
       add_filter( 'grfwp_print_reviews_output', 'johnmccarthy_custom_review_output', 10, 2 );
       function johnmccarthy_custom_review_output( $output, $args ) {
   
       	// Generate whatever HTML markup you want and assign it to $output
       	$output = '<div class="my-gr-review">This is the review</div>';
   
       	// Return the html markup
       	return $output;
       }
       ```
   
 * Of course, you’ll want to look at the [grfwp_print_reviews()](https://github.com/NateWr/good-reviews-wp/blob/master/includes/template-functions.php#L41)
   to see how the `$args` array is used to generate the HTML output, and then generate
   your own. But that function demonstrates how you use a filter to enter your own
   HTML.
 * (I haven’t tested the function above so if it breaks just look for syntax errors
   that may need to be fixed.)
 *  Thread Starter [John McCarthy](https://wordpress.org/support/users/john-lion/)
 * (@john-lion)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/replace-the-print-reviews-function-in-theme/#post-6902488)
 * Thanks Nate,
 * that’s what I hoped. All good for now, as you said works just like template override.
 * I really appreciate your help, all the best with everything.
 *  [NateWr](https://wordpress.org/support/users/natewr/)
 * (@natewr)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/replace-the-print-reviews-function-in-theme/#post-6902489)
 * No problem! If you get a chance, I always appreciate reviews for the plugin [here](https://wordpress.org/support/view/plugin-reviews/good-reviews-wp).

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Replace the print reviews function in theme’ is closed to new replies.

 * ![](https://ps.w.org/good-reviews-wp/assets/icon-128x128.png?rev=2205475)
 * [Five Star Restaurant Reviews](https://wordpress.org/plugins/good-reviews-wp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/good-reviews-wp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/good-reviews-wp/)
 * [Active Topics](https://wordpress.org/support/plugin/good-reviews-wp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/good-reviews-wp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/good-reviews-wp/reviews/)

## Tags

 * [functions](https://wordpress.org/support/topic-tag/functions/)

 * 5 replies
 * 2 participants
 * Last reply from: [NateWr](https://wordpress.org/support/users/natewr/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/replace-the-print-reviews-function-in-theme/#post-6902489)
 * Status: resolved