更好的WordPress主题

WordPress 链接函数 wp_list_bookmarks() 的使用方法和参数介绍

摘要:

WordPress wp_list_bookmarks() 函数是获取链接列表的专用函数,参数丰富,组合查询多变。

WordPress后台的链接功能有很多用途,常见的:友情链接、底部菜单、自定义各种链接模块、图文展示的外链模块等等。

wp_list_bookmarks() 的使用方法

// 以下是默认参数
$args = array(
    'orderby'          => 'name',
    'order'            => 'ASC',
    'limit'            => -1,
    'category'         => '',
    'exclude_category' => '',
    'category_name'    => '',
    'hide_invisible'   => 1,
    'show_updated'     => 0,
    'echo'             => 1,
    'categorize'       => 1,
    'title_li'         => __( 'Bookmarks' ),
    'title_before'     => '<h2>',
    'title_after'      => '</h2>',
    'category_orderby' => 'name',
    'category_order'   => 'ASC',
    'class'            => 'linkcat',
    'category_before'  => '<li id="%id" class="%class">',
    'category_after'   => '</li>',
);
wp_list_bookmarks( $args );
// 默认直接输出代码,参数 echo 为0时不输出

wp_list_bookmarks() 的参数

@type string   $orderby          How to order the links by. Accepts post fields. Default 'name'.
@type string   $order            Whether to order bookmarks in ascending or descending order.
                                 Accepts 'ASC' (ascending) or 'DESC' (descending). Default 'ASC'.
@type int      $limit            Amount of bookmarks to display. Accepts 1+ or -1 for all.
                                 Default -1.
@type string   $category         Comma-separated list of category ids to include links from.
                                 Default empty.
@type string   $category_name    Category to retrieve links for by name. Default empty.
@type int|bool $hide_invisible   Whether to show or hide links marked as 'invisible'. Accepts
                                 1|true or 0|false. Default 1|true.
@type int|bool $show_updated     Whether to display the time the bookmark was last updated.
                                 Accepts 1|true or 0|false. Default 0|false.
@type int|bool $echo             Whether to echo or return the formatted bookmarks. Accepts
                                 1|true (echo) or 0|false (return). Default 1|true.
@type int|bool $categorize       Whether to show links listed by category or in a single column.
                                 Accepts 1|true (by category) or 0|false (one column). Default 1|true.
@type int|bool $show_description Whether to show the bookmark descriptions. Accepts 1|true or 0|false.
                                 Default 0|false.
@type string   $title_li         What to show before the links appear. Default 'Bookmarks'.
@type string   $title_before     The HTML or text to prepend to the $title_li string. Default '<h2>'.
@type string   $title_after      The HTML or text to append to the $title_li string. Default '</h2>'.
@type string   $class            The CSS class to use for the $title_li. Default 'linkcat'.
@type string   $category_before  The HTML or text to prepend to $title_before if $categorize is true.
                                 String must contain '%id' and '%class' to inherit the category ID and
                                 the $class argument used for formatting in themes.
                                 Default '<li id="%id" class="%class">'.
@type string   $category_after   The HTML or text to append to $title_after if $categorize is true.
                                 Default '</li>'.
@type string   $category_orderby How to order the bookmark category based on term scheme if $categorize
                                 is true. Default 'name'.
@type string   $category_order   Whether to order categories in ascending or descending order if
                                 $categorize is true. Accepts 'ASC' (ascending) or 'DESC' (descending).
                                 Default 'ASC'.

本文属原创,转载请注明原文:https://themebetter.com/wp_list_bookmarks.html

感觉很棒,欢迎打赏~

13 打赏
分享到:

评论 (0)

登录后评论
注:有关主题的售前售后请 提交工单

建站!你有充足的理由选择我们

世界上超过43%的网站是由WordPress搭建,而我们是国内最靠谱的WordPress主题开发商
在线工单