How to add links to WordPress: wordpress links-PHP Tutorial

Source: Internet
Author: User
The following describes how to add links to WordPress. The following describes how to add links to WordPress. wordpress links are required for each independent blog, many people choose to add links to WordPress in the sidebar.

Links can be said to be necessary for each independent blog. many people choose to add links to the sidebar, but creating an independent links page is also a good choice. Plug-ins can easily achieve this, but I like native, can do it by myself, or do it by myself. After a while, the method came out.

Common method
The process of creating a page with links is relatively simple. First, create a new page template, use the friend chain function to call the friend chain, and add css beautification.

The specific steps are as follows:

1. create a new template page
Copy the page. php file in the topic and rename it links. php.
Add the following code to the top of the page:

<?php/*Template Name: Links*/?>

Then, put a piece of code similar to the following

<?php the_content(); ?>


The code is as follows:

Site random sorting

<? Php wp_list_bookmarks ('orderby = rand & show_images = 1');?>

Place links. php in the root directory of the topic folder, create a new page, select the newly created "Links" in the page template, and save.
Explain the above code
My_list_bookmarks is a function used by WordPress to call user links. orderby is the sorting method of user links. here I write rand, that is, random show_images is used to control whether to display the user links and Boolean variables, 1 indicates that the variables are displayed, 0 indicates that the variables are not displayed, and other optional parameters are as follows:
Boolean type, used to set whether to display category according to their respective categories
String type, followed by "= link Category ID", then the link under this category is displayed. If not specified, all links are displayed.
String type. if "= name of a link category" is followed, the category name is displayed before the link category, if this field is left blank, the category names of all link categories are displayed (that is, the default format ).
String type, which is the text or code before the link category.
String type, which is the text or code after the link category.
String type. each link category has a "class" attribute (as can be seen from the code above). The default value is linkcat.
String type, sorting by link category, by noun or ID.
'Name' (default)
String type. sort the links in ascending or descending order:
ASC (default)
String type, the header text or code of the link title. the default value is Bookmarks, and it controls whether the connection is listed.
Title_before and title_after
As the name suggests, they are the text or code before and after the header connection. the default value is the h2 tag.
Boolean, whether to display private links.
String type: outputs the classification link of Blogroll with the specified ID. each ID is separated by a half-width comma. All Blogroll categories are displayed by default.
String type. The Blogroll category link of the specified ID is excluded from the entire link list. each ID is separated by a half-width comma. By default, nothing is excluded.
String type, Blogroll sorting method (by default, sort by name, unless this value is left blank), that is, sort by the parameters in the interface we set in the WP background link:
(1) 'id'
(2) 'URL'
(3) 'name'
(4) 'target'
(5) 'description'
(6) 'owner'
(7) 'rating'
(8) 'updated'
(9) 'Rel '-arranged according to the set relationship
(10) 'note'
(11) 'RSS'
(12) 'length'-connection name length settings
(13) 'rand'-random display
String type, set the ascending or descending order
ASC (default)
Integer. it specifies the maximum number of output links. The default value is "-1" and all are output.
String type, the text or code between each connection, image, and description. the default line feed is "n.
Boolean: whether to display the description of each link.
Boolean: whether to display the link level.
Boolean: whether to display the latest timestamp.
Boolean, whether to display all links, or even links that are set as invisible by the administrator, which is allowed by default.

2. add css Beautification. The following is my css for your reference.

.lists {padding: 5px; margin: 25px auto auto 0;}.linkcat {font-size: 12px; font-weight: bolder; padding: 5px; margin-bottom: 15px; list-style: none; clear:both}.lists li h2 {font-size:14px; margin-bottom: 15px; color: #99CC33; }.listcat ul {margin-left: 20px;}.linkcat ul li {float: left; margin-bottom: 20px; margin-left: 20px; padding: 4px 0 4px 6px; width: 150px; border: 1px solid #d9d9d9;}.linkcat ul li a {color: #a4a4a4; text-decoration: none;}.linkcat ul li a img {margin-right: 3px;}.linkcat ul li a:visited {color: #a4a4a4;}.tips {font-size: 14px; margin-bottom: 18px; margin-left: 5px;}

Use jQuery
The implementation steps are as follows:
1. to load the jQuery library, you can directly call the google jQuery library.

The code is as follows:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.