I'd like to add an id to each permalink from a plugin. Jquery just returns the same id for each link. Is there another way I can do this?
add_action('add id for each loop', 'test');
function test() {
?>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("a").each(function(){
$("a").attr('id', '<?php the_ID(); ?>');
});
});
</script>
<?php
}
It works fine if I add it to the template directly so is there a way I can find the code from a plugin and add/edit into content.php (custom? loop) template file?
// add the id
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
// result
<a href="<?php the_permalink(); ?>" id="<?php the_ID(); ?>"><?php the_title(); ?></a>