• Hi, I would like to show in a counter the number of years of the institution I am building a web page for. How can I do that? Do I have to use java script combined with the code? Can you show me an example of how to implement it?

Viewing 1 replies (of 1 total)
  • Thread Starter ruthkl

    (@ruthkl)

    Hi, I found out how to pass dynamic values as parameters to a shortcode.

    In my functions.php I created an own shortcode with an attribute $date_of_birth. Then I calculate the age, and pass it on to the real counter shortcode using do_shortcode().

    function age_counter_shortcode($atts) {
    	 extract( shortcode_atts( array(
    	'date_of_birth'	 => '01.01.2000',
    	 ), $atts ) );
             $counter_value = (date('Y') - date('Y',strtotime($date_of_birth)));
    	
    	return do_shortcode("[jellyfish_counter
    		end='{$counter_value}']");
    	
    }
    add_shortcode('age_counter', 'age_counter_shortcode'); 
    
    • This reply was modified 1 year, 2 months ago by ruthkl.
Viewing 1 replies (of 1 total)
  • The topic ‘Create a dynamic counter’ is closed to new replies.