Toolset: Author frontend filtering with views and ajax

add_shortcode("list-of-authors", "list_of_authors");
function list_of_authors() {
  $out = '<option value="">All</option>';
  $users = get_users();
  foreach ($users as $user) {
    $selection = (isset($_GET['author-filter']) ? $_GET['author-filter']: '');
    $out .= '<option ' . selected($user->ID, $selection, false) . ' value="' . $user->ID . '">' . $user->display_name . '</a>';
  }
  return $out;
<select name="author-filter" class="js-wpv-filter-trigger">[list-of-authors]</select>

Visto en: https://toolset.com/forums/topic/author-frontend-filtering-with-views-and-ajax/

Deja un comentario

Tu dirección de correo electrónico no será publicada.

Ir arriba

We are using cookies on our website

Please confirm, if you accept our tracking cookies. You can also decline the tracking, so you can continue to visit our website without any data sent to third party services.