Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PHP - add to functions.php
- ++++++++++++++++++++++++++
- add_action( 'wp_enqueue_scripts', 'gmh_enqueue_scripts' );
- function gmh_enqueue_scripts() {
- global $post;
- $postid = get_the_ID();
- if ( is_singular( 'job_listing' ) {
- $v1 = get_post_meta($postid, '_gmh_vid', true); //use your own field name
- $v2 = get_post_meta($postid, '_gmh_vid2', true); //use your own field name
- $v3 = get_post_meta($postid, '_gmh_vid3', true); //use your own field name
- $second_tab = get_post_meta($postid, '_your_field', true);
- $urls = array(
- $v1,
- $v2,
- $v3
- );
- $tab2 = ($second_tab ? true : "");
- $populated = array_filter($urls);
- $count[] = count($populated);
- wp_enqueue_script( 'gmh-js', get_stylesheet_directory_uri() . '/js/gmh.js');
- wp_localize_script( 'gmh-js', 'gmhVar', array(
- 'tab1' => $count,
- 'tab2' => $tab2
- ) ); //passes our array variables to gmhVar in our script
- }
- }
- JS - replace for 2 tabs
- ++++++++++++++++++++++++++
- (function($) {
- $(document).ready(function(){
- var counted = gmhVar.tab1;
- if (counted >= 1) {
- $( "<span class='items-counter'>" + counted + "</span>").appendTo( "#listing_tab_video_toggle" );
- } else {
- $("#listing_tab_video_toggle").addClass('hide');
- }
- var element2 = Boolean(gmhVar.tab2);
- if (element2 === false) {
- $("#listing_tab_yelp_toggle").addClass('hide');
- }
- });
- })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement