Home › Forums › JavaScript › [Solved] AnythingSlider & WordPress – the_title(); -> Slidernames
- This topic is empty.
-
AuthorPosts
-
September 27, 2010 at 8:35 am #30375logan91kMember
Hi guys,
I’m pretty new to all this jquery stuff… I’ve implented a part of the slider in WordPress, but now I need to change the “Slidernames” in the navbar…
At the moment my “wordpress loop” looks like this:
';
the_post_thumbnail( array(880,880) );
the_content();
echo '
No Content. :-(
';
// The Loop
if (have_posts()) : while (have_posts()) : the_post();
echo '
';
endwhile; else:
echo '
endif;
?>
Now i need to get the “Post Titles” (wordpress: the_title();) to be shown instead of the numbers… any idea?
Thx!
loganSeptember 27, 2010 at 10:57 am #78942ak-iParticipantWhat numbers may I ask?
September 27, 2010 at 12:05 pm #78948TheDocMemberYes, what numbers are showing up that you want to replace? Do you have a link to the page so that we can see it in action?
September 27, 2010 at 3:20 pm #78952logan91kMemberno sorry, aint got a link… (but still looks like this, https://css-tricks.com/examples/AnythingSlider/ just uses the wordpress posts as slides)
well, i mean the “slidenumbers” from the anythingslider (the things/links below the slides)… I need to get the “wordpress post titles” into the “formatText” function to replace the “Slidenumbers”…
function formatText(index, panel) {
return index;
};I’m not really good with jquery, I’m more the php guy… I just have no clue how i can bring something i get from wordpress into a jQuery function…
September 27, 2010 at 4:23 pm #78954jamygoldenMemberHow about
var totalSlides = $(".thumbNav li").not("arrow").size();
for(var i=0; i <= totalSlides; ++i){
$(".anythingSlider .thumbNav li").not(".cloned").eq(i).children("a")
.text(
$(".anythingSlider .wrapper ul li").eq(i).find("h2").text()
);
}– Variable totalSlides is the number of .thumbNav li’s that don’t have the class of “arrow”.
– A for loop that is looped the amount of times as there are slides
– Target the thumbNav li’s that don’t have a class of cloned (Anything slider has a cloned first and last slide)
– eq() is the index. Starts on 0. We are planning on matching up the index of the slides with the index of the number.
– Select the child <a> and change it’s text to
– The matched slide (Via index)
– Find the text of the <h2> contained within this List item (Assuming the Title is contained within the h2)I don’t think there is a native option within anythingSlider to change the text of these paginated numbers.
Note: I have not tested this.
September 28, 2010 at 4:43 am #78973logan91kMember@jamy_za, thank you, because of ur post I found a solution… :)
In case anybody else wants to use it, here it is.
This is my “formatText” jQuery function:function formatText(index, panel) {
var title = $(panel).find("h2").text();
return title;
};(“panel” contains the full post by default (everything inside the LI))
and this is my “WordPress Loop”:
';
the_post_thumbnail( array(880,880) );
echo '';
';
the_title();
echo '
the_content();
echo '
No Content. :-(
';
// The Loop
if (have_posts()) : while (have_posts()) : the_post();
echo '
';
endwhile; else:
echo '
endif;
?>
works! :-) But only if you have only one H2 Element in the post… a second one could mess this up (not tested)
Oh, and this should be set in the anythingSlider “Options”:
navigationFormatter: formatText // Details at the top of the file on this use (advanced use)
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.