Advertisement
chrishajer

Cookie shortcode to use as a default value

Nov 14th, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.36 KB | None | 0 0
  1. <?php
  2. // shortcode to grab a cookie
  3. // usage: [cookie name='whatever']
  4. // paste this code into your theme's functions.php file
  5. if (!function_exists('ch_get_cookie')) {
  6.     function ch_get_cookie($atts) {
  7.         extract(shortcode_atts(array(
  8.             'name' => null
  9.         ), $atts));
  10.         $output = $_COOKIE[$name];
  11.         return $output;
  12.     }
  13. }
  14. add_shortcode('cookie', 'ch_get_cookie');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement