看起来是默认值get_bookmarks()
http://codex.wordpress.org/Function_Reference/get_bookmarks
正在使用此查询:
SELECT * FROM wp_links WHERE 1=1 AND link_visible = \'Y\' ORDER BY link_name ASC;
您可以在中检查功能
/wp-includes/bookmark.php
.
这个get_bookmarks()
函数具有limit
和order
您可能会发现有用的参数。
选项get_bookmarks("limit=5")
提供此查询:
SELECT * FROM wp_links WHERE 1=1 AND link_visible = \'Y\' ORDER BY link_name ASC LIMIT 5
类别参数
get_bookmarks("category=1")
给你这个
JOIN
:
SELECT * FROM wp_links
INNER JOIN wp_term_relationships AS tr ON (wp_links.link_id = tr.object_id)
INNER JOIN wp_term_taxonomy as tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
WHERE 1=1 AND link_visible = \'Y\' AND ( tt.term_id = 1 ) AND taxonomy = \'link_category\'
ORDER BY link_name ASC;
因此,如果不使用类别参数,这些参数很简单
SELECT
使用
$wpdb
数据库对象。
Edit: 如果要搜索特殊link_owner
您可以使用以下示例:
global $wpdb;
$link_owner=1; // EDIT this value
$sql="SELECT * FROM wp_links WHERE link_visible = \'Y\' AND link_owner = %d ORDER BY link_name ASC;";
$results = $wpdb->get_results($wpdb->prepare($sql,$link_owner));