php - get_the_title() of some post and work with it's value -
php - get_the_title() of some post and work with it's value -
i have standart loop with:
<article class="somepost"> <?php $a = get_the_title(); echo $a; ?> </article>
how value of post's title, when click on article (class="somepost")
$('.somempost').click(function(){ ??? });
thanx.
first, set title articles info attribute:
<?php $a = get_the_title(); ?> <article class="somepost" data-title="<?php echo $a; ?>"> <?php echo $a; ?> </article>
then in jquery, set title variable so:
$('.somepost').click(function(){ var the_title = $(this).data('title'); });
php jquery wordpress
Comments
Post a Comment