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

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -