Support

Account

Home Forums ACF PRO Using Parameters inside Shortcodes Reply To: Using Parameters inside Shortcodes

  • I reworked my code to look like this and everything is working so far!

    <?php
    /**
     * Shortcode: [deptlist department=""]
     * Description: This is how stuff works with parameters
     */
    
    function dept_option($atts){
    	
    	extract(shortcode_atts( array(
    		'department' => 'Legal Studies',
    	
    	), $atts ));
    	$myfinalcode = '"' . $department . '"';
    	
    	$args1 = array(
    		'meta_key' => 'last_name',
    		'orderby' => 'meta_value',
    		'order' => 'ASC',
    		'exclude' => array(1,8,9),
    		'meta_query' => array(
    			'relation' => 'AND',
    			'department' => array(
    				'key' => 'department',
    				'value' => $myfinalcode, 
    				'compare' => 'LIKE',
    			),
    		)
    	);
    	$subscribers = get_users($args1);
    		echo '<ul>';
     			foreach ($subscribers as $user) {
     			echo '<li>' . $user->display_name.' ['.$user->phone_number . ']</li>';
     			}
    		echo '</ul>';
    	
    // ENDING ROW	
    }
    add_shortcode( 'deptlist', 'dept_option' );
    ?>