Created
December 6, 2017 13:00
-
-
Save leepettijohn/a95ad58364e1ea18865fc273b44ef135 to your computer and use it in GitHub Desktop.
WordPress custom toggle on Archive Loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* *** add the below code to the page where all the information that should be displayed in the Loop */ | |
/* *** this is the link to click */ ?> | |
<a class="more-info-link <?php tribe_events_event_classes() ?>" style="cursor:pointer">More Info</a> | |
<? /* *** this is the box that holds more info */ ?> | |
<div class="more-info <?php tribe_events_event_classes() ?>" style="display:none;"> | |
<? /* *** This is where all the info goes that should be in the hidden box */ ?> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function($){ | |
/* when you click the link ... */ | |
$('.more-info-link').click(function(){ | |
var check = "post-"; | |
/* split all the classes into an array ... */ | |
var cls = $(this).attr('class').split(' '); | |
for (var i = 0; i < cls.length; i++) { | |
/* if the start of the class in the array is also the start of the "check" variable denoted above ... */ | |
if (cls[i].indexOf(check) > -1) { | |
/* get the number of the post ... */ | |
var postnum = cls[i].slice(check.length, cls[i].length); | |
} | |
} | |
/* and open the box with the same number in the class as the open link */ | |
$('.more-info.post-'+postnum).toggle('slow'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment