Hello,
Thank you very much for taking the time. I sincerely appreciate it. Please let me know at any time if I can help further with testing.
When I insert the code into my child theme’s functions.php file, the entire site gets an error:
“The site is experiencing technical difficulties. Please check your site admin email inbox for instructions.”
And then when I go to my email I see the following:
“Hi there!
Since WordPress 5.2 there is a built-in feature that detects when a plugin or theme causes a fatal error on your site, and notifies you with this automated email.
In this case, WordPress caught an error with your theme, OceanWP Child.
First, visit your website (https://molomarket.com/) and check for any visible issues. Next, visit the page where the error was caught (https://molomarket.com/wp-admin/admin-ajax.php?_fs_blog_admin=true) and check for any visible issues.
Please contact your host for assistance with investigating this issue further.
If your site appears broken and you can’t access your dashboard normally, WordPress now has a special “recovery mode”. This lets you safely login to your dashboard and investigate further.
https://molomarket.com/wp-login.php?action=enter_recovery_mode&rm_token=55PWI8iSXp4oWyDsL5ZyBL&rm_key=YDh3QpFo8ijMWtIbb7lUSJ
To keep your site safe, this link will expire in 1 day. Don’t worry about that, though: a new link will be emailed to you if the error occurs again after it expires.
Error Details
=============
An error of type E_COMPILE_ERROR was caused in line 234 of the file /home/molomark/public_html/wp-content/themes/oceanwp-child-theme-master/functions.php. Error message: Cannot redeclare aws_excerpt_search_result() (previously declared in /home/molomark/public_html/wp-content/themes/oceanwp-child-theme-master/functions.php:193)”
—————————————–
So as you can see there is an error.
Now I wonder whether the error is occurring because we already have another AWS method in the functions.php file? Or will they not interfere with one another? These both have the same function:
function aws_excerpt_search_result
When I put a random number or letter after that function name, then the site’s error message goes away and I can proceed to use the website. So for example in Method One (below), I change the function title to:
function aws_excerpt_search_result1
I put that “1” there as a random character so that it did not have the same function as Method Two. Then the error message on the site went away.
However, I still cannot search for a vendor. If I type in a vendor’s name such as Ashley, no products pop up.
Please see the methods below (I have left them as I received them from you):
//METHOD ONE
add_filter( ‘aws_indexed_title’, ‘aws_indexed_title’, 10, 2 );
function aws_excerpt_search_result( $title, $post_id ) {
if ( function_exists( ‘get_wcmp_product_vendors’ ) ) {
$vendor = get_wcmp_product_vendors( $post_id );
if ( $vendor && $vendor->user_data->display_name ) {
$title = $title . ‘ ‘ . $vendor->user_data->display_name;
}
}
return $title;
}
//METHOD TWO
add_filter( ‘aws_excerpt_search_result’, ‘aws_excerpt_search_result’, 10, 2 );
function aws_excerpt_search_result( $excerpt, $post_id ) {
if ( function_exists( ‘get_wcmp_product_vendors’ ) ) {
$vendor = get_wcmp_product_vendors( $post_id );
if ( $vendor && $vendor->user_data->display_name ) {
$excerpt = $excerpt . ‘<br>’ . ‘Vendor: ‘ . $vendor->user_data->display_name;
}
}
return $excerpt;
}