Skip to content

Forum in maintenance, we will back soon ๐Ÿ™‚

Adding extra ai too...
 
Notifications
Clear all

Adding extra ai tools in WordPress on the same page using Elementor

7 Posts
3 Users
5 Reactions
36 Views
 Jon
(@jonr)
Posts: 7
Member Registered
Topic starter
 

Hi Hasan. I have been able to add a fully functional AI tool to my WP site by following your guide here - https://learnwithhasan.com/create-ai-tools-with-wordpress/ but I am wanting to add multiple tools that use different prompts to the same page as shown in the attached image, but any additional tools I add don't work when I press the blue button. I have successfully changed the prompts in the code, just can't get additional tools to work, unless I delete all but one of them. Would you mind letting me know how I can change the code to allow more than one script work on the same page please, and the process behind it, so I can learn how to do it in future projects going forward?ย  Thank you ๐Ÿ™‚ย 

ย 

 
Posted : 08/20/2023 4:07 pm
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

Do you use different function names? You'll need to do that.

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 08/21/2023 2:59 am
Jon reacted
Hasan Aboul Hasan
(@admin)
Posts: 1276
Member Admin
 

Yes you can, but u will need to change function names in both us code and php

 
Posted : 08/21/2023 6:32 am
Jon reacted
 Jon
(@jonr)
Posts: 7
Member Registered
Topic starter
 

Hi guys thanks for you feedback ๐Ÿ™‚ No I hadn't changed any functions, but have been trying for a while now, and still cant get it working the second tool working unless i delete the first one.

Are you referring to editing this part of the WP Code backend snippet -ย 

function openai_generate_text() {
// Get the topic from the AJAX request
$prompt = $_POST['prompt'];

The only JS I can find that mentions functions on the page the tools are on is -ย 

document.getElementById("generate-button").addEventListener("click", function(e){
e.preventDefault();

and the copy to clipboard code -ย 

copyButton.addEventListener('click', function() {
var result = document.getElementById('result');

ChatGPT code Interpreter keepsย telling me I need change the EventListeners.

Been trying for the last few hours to get this working, but I am out of ideas, if you could elaborate further on what I need to do, that would be great, thanks again ๐Ÿ™‚ย ย 

ย 

ย 

 
Posted : 08/21/2023 11:42 am
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

@jonr When pasting code please use the code (<>) icon. We were referring to the names of the functions.

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 08/21/2023 3:57 pm
Jon reacted
Hasan Aboul Hasan
(@admin)
Posts: 1276
Member Admin
 

@jonr In the PHP Snippet, you need to change the function name in 3 places.

And in the JS code change the function that we are calling.

 
Posted : 08/23/2023 6:32 am
Jon reacted
 Jon
(@jonr)
Posts: 7
Member Registered
Topic starter
 

Will do, thank you both ๐Ÿ™‚

 
Posted : 08/23/2023 8:17 am
Share:
[the_ad_group id="312"]