php - Having trouble acquiring the current posts title -
i working in wordpress , have link supposed play wav
file depending on title of post. if post title 'one'
should play one.wav
uploads folder. however, sound file on every post plays current posts title. if added post called two
, post called one
, both posts play one.wav
.
here's code:
html
<span id="dummy"></span> <a class="playsound" onclick="playsound();" href="#"> <i class="fa fa-volume-up"></i> </a>
jquery
function playsound() { $.ajax({ url: 'sound.php', data: "getsound", type: "get", datatype: "html", success: function(data) { document.getelementbyid("dummy").innerhtml= "<embed src=\""+data+"\" hidden=\"true\" autostart=\"true\"loop=\"false\" />"; } }); }
and php
<?php require('./wp-blog-header.php'); if(isset($_get['getsound'])) { $file='wp-content/uploads/2015/wav/' . get_the_title() . '.wav'; echo $file; } ?>
i assume get_the_title()
proper call @ point not sure. have tried other call functions still no luck. assume @ point has loading of page , storing initial posts title lost @ point.
<?php $sound_query = new wp_query(); if ($sound_query->have_posts()): while ($sound_query->have_posts()): $sound_query->the_post(); ?> <script> function playsound() { document.getelementbyid("dummy").innerhtml= "<embed src='wp-content/uploads/2015/wav/<?php echo get_the_title() ?>.wav' />"; } </script> <?php endwhile; endif; wp_reset_postdata(); ?>
Comments
Post a Comment