Looping through posts to find and create titles for tumblr photo posts
I am creating a Tumblr theme and have run into a road block. Tumblr unfortunately does not allow for titles for the Photo post type. As such I have decided I want to take the p:first-child
in each aside
(where I am housing the caption / blog text) and replace the generic 开发者_如何学JAVAhgroup h3 a
(the posts title) content with the p:first-child
content i've selected; thus creating a title.
Hopefully this doesn't sound to convoluted. I am using jQuery for most animated elements on the page and would like to continue using jQuery to accomplish this task.
Here is the current code I am using:
$('section').each(function(index) {
$('hgroup h3 a').append( $('aside p:first-child em') );
});
the problem is that it's returning an array of all p:first-child elements resulting in 5 titles where only one should appear.
What I would like is to take each of the first-child elements that are found, and place each individual item in place of their parent title element.
Any help that could be provided would be great!
If each aside
is contained in it's own section
you could do this:
$('section').each(function(index) {
$('hgroup h3 a', this).append( $('aside p:first-child em', this) );
});
精彩评论