SHARE
TWEET

Untitled

a guest Jul 17th, 2017 41 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. /**
  4.  * Adds "user defined" shortcodes via ACF options and repeater plugins
  5.  */
  6. function addUserDefinedShortCodes()
  7. {
  8.     if( have_rows('codes','option') ):
  9.  
  10.         // loop through the rows of data
  11.     while ( have_rows('codes','option') ) : the_row();
  12.         $content = get_sub_field('sc_content');
  13.         add_shortcode(get_sub_field('shortcode'), function() use ($content) {
  14.             return $content;
  15.         });
  16.  
  17.         endwhile;
  18.  
  19.     endif;
  20. }
RAW Paste Data
Top