You get a bonus - 1 coin for daily activity. Now you have 1 coin

WORDPRESS 13. Sidebar: work with archives and links blogroll.

Lecture



Today's lesson is quite simple. We will learn to call a list of links to archives and blog blogs (a list of links to blogs or websites). And next time we will look at the calendar and the “Search” field.

Before starting, I want to explain why I began to break my lessons into smaller ones. Everything that you are studying now has required a lot of time for those who studied themselves to sort out and systematize their knowledge. It is important for me that you understand everything the first time so that you do not have to go back and reread the lessons.

Step 1

Add links to archive records. Paste the following code in the sidebar area, below the category list:

?
one
2
3
four
five
<li><h2><?php _e('Archives'); ?></h2>
<ul>
<?php wp_get_archives('type=monthly'); ?>
</ul>
</li>

Let's see if your code matches mine:

  WORDPRESS 13. Sidebar: work with archives and links blogroll.

Save the file, refresh the browser, here is the result:

  WORDPRESS 13. Sidebar: work with archives and links blogroll.

What happened?

You used the wp_get_archives () function with a type attribute and a monthly value to call up a list of archives, grouped monthly.

  • <li> - open the list item
  • <h2> - open subtitle
  • <? php _e ('Archive'); ?> - subtitle text
  • </ h2> - close the subtitle
  • <ul> - open an unnumbered list under the subtitle, in the structure of the list item.
  • <? php wp_get_archives ('type = monthly'); ?> - call archives, grouped monthly, place each link between tags <li> and </ li> tags. If you check the source code, you will see that the wp_get_archives () function generated list item ( LI ) tags for each link, exactly like the wp_list_categories () function.
  • </ ul> - close an unnumbered list, which is under the subtitle
  • </ li> - close the list item

Step 2

Add links to the blogs feed. Type the following code under the archive list:

<? php get_links_list (); ?>

  WORDPRESS 13. Sidebar: work with archives and links blogroll.

Save the file, update the window, here is the result:

  WORDPRESS 13. Sidebar: work with archives and links blogroll.

By default, my blog feed is no different from yours. Here’s what it looks like in the source code:

  WORDPRESS 13. Sidebar: work with archives and links blogroll.

Code organization is not perfect, because the get_links_list () function generates the code for you, just like the wp_list_pages () function that you met in the last lesson.

That's all for today. In the next lesson you will learn about the calendar and search.


Comments


To leave a comment
If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Content Management Systems (CMS)

Terms: Content Management Systems (CMS)