我正在尝试根据它们的类别显示一些项目。这是我的代码。
$cat=array("all","coding","registry","analytics");
list($a,$b,$c,,$d)=$cat;
$members .='<ul>';
$members .='<li onclick="case_studies_get_some($a)">All</li>';
$members .='<li onclick="case_studies_get_some($b)")">Coding</li>';
$members .='<li onclick="case_studies_get_some($c)">Registry</li>';
$members .='<li onclick="case_studies_get_some($d)">Analytics</li>';
$members .='</ul>';
return $members;
$output .= '<ul class="team-members-list">';
foreach( $members as $member ) {
$output .= case_studies_display_one( $member );
}
$output .= '</ul>';
return $output;
}
通过单击特定标签,它应该调用以下函数
function case_studies_get_some(&$cat){
global $wpdb;
$table_name = $wpdb->prefix . "case_studies";
$query = $wpdb->prepare("SELECT * FROM $table_name where category = %s ORDER BY name",
$cat);
$rows = $wpdb->get_results( $query, ARRAY_A );
$results = array();
foreach ( $rows as $row ) {
$row['image'] = $row['imageloc'];
$row['website'] = $row['url'];
unset( $row['imageloc'] );
array_push( $results, $row );
}
return $results;
}
但它不起作用。我认为 onclick 事件不起作用..请有任何建议..