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' );
?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.