Reputation: 3469
I have this code which detects the last image in the images in my Wordpress post
I want to alter it to put the div #up-arrow over-top the last image.
html
<?php
preg_match_all('/(<img [^>]*>)/', get_the_content(), $images);
for( $i=0; isset($images[1]) && $i < count($images[1]); $i++ ) {
if ($i == end(array_keys($images[1]))) {
echo sprintf('<div id="last-img">%s</div>', $images[1][$i]);
continue;
}
echo $images[1][$i];
}
?>
css
#up-arrow { position: absolute; z-index: 10; }
Upvotes: 0
Views: 159