Remove first element loop php (loop wordpress) and use it in javascript

0

How can I get the the_title () from the first post that runs the while and then extract it for use in the javascript functions? the first the_title () is plan, but I want to avoid hardcode it since it could be updated in the future.

<script type="text/javascript">
window.onload = function onload(){
    // primer elemento.id hardcodeado
    document.getElementById('plan').style.display = 'block';
}
</script>

<script type='text/javascript'>
var sw=0;
var anterior="";
function show(objeto){  
    if (objeto!=anterior){
        // primer elemento.id hardcodeado
        document.getElementById('plan').style.display = 'none';
        document.getElementById(objeto).style.display = 'block';
        if (sw==1){
            document.getElementById(anterior).style.display = 'none';   
        }
        anterior=objeto;
        sw=1;
    }
}   
</script>

<?php
query_posts("category_name=x" . "&order=asc" . "&posts_per_page=-1");
while ( have_posts() ) : the_post();
get_template_part( 'contetn', 'page' );
endwhile;
?>
    
asked by dpfernandez10 19.04.2018 в 15:22
source

0 answers