PHP Shortcode to display the price works on frontend but breaks the editor
-
Hello
On a specific template in Astra Theme, I try to display the price of the current product.
To do so, I put à PHP code in the functions.php file to create à shortcode.Error message when trying to save the publication : Update failed
When trying to reload the page, or access it again from the dashboard; I got the lightgray screen with the critical error message.If I disable the code, save the page with the sort code in it, then reactivate the code in the function file, here is what happening :
The dashboard, and the frontend are working fine, the shortcode works and display the price on the frontend, but the page in the backend where I put the shortcode is broken.
Here is the php code I put in function.php :
add_shortcode( 'avv-woo-price', function () { $product = wc_get_product(get_the_ID()); $thePrice = $product->get_price_html(); return $thePrice; } );
Could you please help me find what I miss ?
Thank you very much !
The page I need help with: [log in to see the link]
- The topic ‘PHP Shortcode to display the price works on frontend but breaks the editor’ is closed to new replies.