wordpress代码实现下拉友情链接
很多企业网站的左下方都有一个下拉的友情链接,这个该怎么实现呢?其实很简单,在主题的function.php文件中添加以下代码: `function dropdown_links(){ global $wpdb; $sql = “SELECT link_url, link_name, link_description FROM $wpdb->links WHERE link_visible = ‘Y’ Order By link_name”; $results = $wpdb->get_results($sql); if (!$results) { return; } $output =’
Select … ‘; foreach ($results as $row) { $the_link = ‘#’; if (!empty($row->link_url)){ $the_link = wp_specialchars($row->link_url); } $desc = wp_specialchars($row->link_description, ENT_QUOTES); $name = wp_specialchars($row->link_name, ENT_QUOTES); $title = $desc; if (‘’ != $title) { $title = ‘ title=”‘ . $title . ‘“‘; } $alt = ‘ alt=”‘ . $name . ‘“‘; $output .= ‘’.$name.’’; } $output .= ‘
‘; echo $output; }` 然后在使用下拉友情链接的地方 添加 即可,css样式你可以按照自己的爱好来自行定义,OK !!