Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript [Solved] AnythingSlider & WordPress – the_title(); -> Slidernames

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #30375
    logan91k
    Member

    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 Loop
      if (have_posts()) : while (have_posts()) : the_post();
      echo '


    • ';
      the_post_thumbnail( array(880,880) );
      the_content();
      echo '


    • ';
      endwhile; else:
      echo '


    • No Content. :-(

    • ';
      endif;
      ?>


    Now i need to get the “Post Titles” (wordpress: the_title();) to be shown instead of the numbers… any idea?

    Thx!
    logan

    #78942
    ak-i
    Participant

    What numbers may I ask?

    #78948
    TheDoc
    Member

    Yes, 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?

    #78952
    logan91k
    Member

    no 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…

    #78954
    jamygolden
    Member

    How 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.

    #78973
    logan91k
    Member

    @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 Loop
      if (have_posts()) : while (have_posts()) : the_post();
      echo '

    • ';
      the_post_thumbnail( array(880,880) );
      echo '

      ';
      the_title();
      echo '

      ';
      the_content();
      echo '


    • ';
      endwhile; else:
      echo '


    • No Content. :-(

    • ';
      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)
Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.