Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

159
Visualizações
I have a previuos easy HTML page with script linked to js files, for an AI test. How to link or to import to a wordpress site I'm testing on my own pc

Below the easy HTML code, taken from a tensorflow example. I have created on my own pc a wordpress site, just for test, and I would like to add the page or the contents of the page to the web site. Two ways: the first one, the preferred, try to integrate the HTML code and js file ( which mantain tensorflow commands, not related with themes) into a wordpress page. No problem for the HTML but I can not find the way to link the js file. I have tried modifying function.php, using wp_enqueue_script, but I don't understand where to store the js file according, and the path to specify. If it work in preview, it does'nt work when I public the page. Also some other methods with no success. The second way is linking the old html page, but where I should insert the html file and the js file?

Thanks for your help, I'm really stuck.

<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@latest"> </script>
<script src="webcam.js"></script>
<script src="rps-dataset.js"></script>
</head>
<body>
    <div>
        <div>
            <video autoplay playsinline muted id="wc" width="224" height="224"></video>
        </div>
    </div>
    <button type="button" id="0" onclick="handleButton(this)" >Rock</button>
    <button type="button" id="1" onclick="handleButton(this)" >Paper</button>
    <button type="button" id="2" onclick="handleButton(this)" >Scissors</button>
    <div id="rocksamples">Rock Samples:</div>
    <div id="papersamples">Paper Samples:</div>
    <div id="scissorssamples">Scissors Samples:</div>
    <button type="button" id="train" onclick="doTraining()" >Train Network</button>
    <div id="dummy">Once training is complete, click 'Start Predicting' to see predictions, and 'Stop Predicting' to end</div>
    <button type="button" id="startPredicting" onclick="startPredicting()" >Start Predicting</button>
    <button type="button" id="stopPredicting" onclick="stopPredicting()" >Stop Predicting</button>
    <div id="prediction"></div>
</body>

<script src="index.js"></script>
</html>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I guess the best approach would be to create a custom page template.

Are you using a custom theme or a theme from the wordpress theme repository? I'm asking as the latter will frequently be updated and override customized option like those in your functions.php. In this case you might create a child theme.

See this description: Create Child Themes

You can then create a custom page template by creating a new file like
"page-tmpl-tensor.php" in your theme/child theme folder.

Its content is actually pretty close to your html code but it needs some wordpress specific funtions/variables to work

<?php 
/* 
   Template name: tensorflow 
   Template Post Type: post, page
*/ 
$theme_url = get_template_directory_uri();
?> 
<html>
<head>
<link rel="stylesheet" href="<?php echo $theme_url; ?>/tensor.css">
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@latest"> </script>
<script src="<?php echo $theme_url; ?>/webcam.js"></script>
<script src="<?php echo $theme_url; ?>/rps-dataset.js"></script>
</head>
<body>
    <div>
        <div>
            <video autoplay playsinline muted id="wc" width="224" height="224"></video>
        </div>
    </div>
    <button type="button" id="0" onclick="handleButton(this)" >Rock</button>
    <button type="button" id="1" onclick="handleButton(this)" >Paper</button>
    <button type="button" id="2" onclick="handleButton(this)" >Scissors</button>
    <div id="rocksamples">Rock Samples:</div>
    <div id="papersamples">Paper Samples:</div>
    <div id="scissorssamples">Scissors Samples:</div>
    <button type="button" id="train" onclick="doTraining()" >Train Network</button>
    <div id="dummy">Once training is complete, click 'Start Predicting' to see predictions, and 'Stop Predicting' to end</div>
    <button type="button" id="startPredicting" onclick="startPredicting()" >Start Predicting</button>
    <button type="button" id="stopPredicting" onclick="stopPredicting()" >Stop Predicting</button>
    <div id="prediction"></div>
</body>

<?php wp_footer(); ?>
<script src="<?php echo $theme_url; ?>/index.js"></script>
</html>
<!-- tensorflow -->

You can now create a new page in the wordpress admin area and should see your template "tensorflow" listed in the page template dropdown.

You might also replace the body content with thes lines to retrieve the content dynamically:

    <?php 
    setup_postdata($post->ID);  
    echo get_the_content(); 
    ?>

Now you could paste and edit your body html in the page's content field. In this case make sure you paste the html in html/text mode.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda