get_linkobjectsbyname

函式
get_linkobjectsbyname ( $cat_name = "noname", $orderby = 'name', $limit = -1 )
引數
  • (string) $cat_name Optional. The category name to use. If no match is found, uses all. Default 'noname'.
    Required:
    Default: "noname"
  • (string) $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url', 'description', 'rating', or 'owner'. Default 'name'. If you start the name with an underscore, the order will be reversed. Specifying 'rand' as the order will return links in a random order.
    Required:
    Default: 'name'
  • (int) $limit Optional. Limit to X entries. If not specified, all entries are shown. Default -1.
    Required:
    Default: -1
返回值
  • (array)
相關
  • get_bookmarks()
定義位置
相關方法
get_linksbynameget_linkobjectsget_linkcatnamewp_get_linksbynameget_object_subtype
引入
1.0.1
棄用
2.1.0

get_linkobjectsbyname: 這個函式用來檢索一個給定連結類別名稱的連結物件陣列。

獲取與類別$cat_name相關的連結物件陣列。

$links = get_linkobjectsbyname( ‘fred’ );
foreach ( $links as $link ) {
echo ‘

  • ‘ . $link->link_name . ‘
  • ‘;
    }

    Plain text
    Copy to clipboard
    Open code in new window
    EnlighterJS 3 Syntax Highlighter
    function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) {
    _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' );
    $cat_id = -1;
    $cat = get_term_by('name', $cat_name, 'link_category');
    if ( $cat )
    $cat_id = $cat->term_id;
    return get_linkobjects($cat_id, $orderby, $limit);
    }
    function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) { _deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' ); $cat_id = -1; $cat = get_term_by('name', $cat_name, 'link_category'); if ( $cat ) $cat_id = $cat->term_id; return get_linkobjects($cat_id, $orderby, $limit); }
    function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) {
    	_deprecated_function( __FUNCTION__, '2.1.0', 'get_bookmarks()' );
    
    	$cat_id = -1;
    	$cat = get_term_by('name', $cat_name, 'link_category');
    	if ( $cat )
    		$cat_id = $cat->term_id;
    
    	return get_linkobjects($cat_id, $orderby, $limit);
    }

    常見問題

    FAQs
    檢視更多 >