jQuery slideUp() functions.php for archive page
-
Hi,
I have a jQuery script that looks like this:$(".toggle").slideUp(); $(".toggle-link").click(function(){ $('.toggle').removeClass("hidden"); $(this).prev(".toggle").slideToggle("slow"); $(this).text($(this).text() == 'Close ✕' ? 'Read more' : 'Close ✕'); });I’ve used a plugin for WordPress called “Ultimate WP Query Search Filter”. To be able to style the output from the filtering I’ve got an add_filter() script in functions.php where I’ve put the html to call the script above:
add_filter('uwpqsf_result_tempt', 'customize_output', '', 4); function customize_output($results , $arg, $id, $getdata ){ // The Query $apiclass = new uwpqsfprocess(); $query = new WP_Query( $arg ); ob_start(); $result = ''; // The Loop if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post();global $post; echo '<a class="toggle-link"><h4>Read more ▾</h4></a>'; echo '<div class="toggle hidden" style="display: none">Hi</div>'; } echo $apiclass->ajax_pagination($arg['paged'],$query->max_num_pages, 4, $id, $getdata); } else { echo 'no post found'; } /* Restore original Post Data */ wp_reset_postdata(); $results = ob_get_clean(); return $results; }Whenever I use the script and code on other parts of the page it works flawless, but as soon as I put it in functions.php it stop working. Has anyone a clue why it’s doing this?
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
The topic ‘jQuery slideUp() functions.php for archive page’ is closed to new replies.