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

WORDPRESS 14. Search field and calendar.

Lecture



Although the title of the lesson is “Search field and calendar” , I will talk a little about the Meta block. Let's finish looking at the standard sidebar today and the next time we finally find out how to widget it. Well, let's go ...

Step 1

Add a search field. Before I give you the code, create a new file in the editor, leave it clean and save it as searchform. php (of course, in the same folder as the index. php file). Copy the code from the searchform.txt file into your searchform file . php . For now, let's temporarily leave the searchform file on this . php alone

In the index.php file, type the following code, above all the lists in the sidebar:

?
one
2
3
  • "search" >
include (TEMPLATEPATH . '/searchform.php' ); ?> ); ?>

Save the file and refresh the browser. Here is the result:

WORDPRESS 14. Search field and calendar.

What happened?

  • < li id = ” search ”> - open the list item with the search ID. You assign an ID to it so that you can stylize it later.
  • include () - include any file you want. This function is different from the WordPress template function because the function include () simply includes what is already there. In this case, this is the code from the searchform file . php . The information that is included does not change with the blog. In other words, my “Search” field looks exactly like yours.
  • TEMPLATEPATH - the location of the folder with your theme, wp-content / themes / tutorial
  • '/searchform.php' - location and file name, /searchform.php
  • The point between TEMPLATEPATH and '/searchform.php' connects them, so you end up with:
    wp-content / themes / tutorial / searchform.php
  • - close the list item

Note that the search box does not have a subtitle like Categories, Archives, Pages or Blog feeds . You can give it a subtitle if you want, but in order for your sidebar to be as close as possible to the widget version, you do not need to subtitle.

Step 2 :

Add a calendar. Enter the following code below the search field or page list block:

?
one
2
3
four
  • "calendar" >

    'Календарь' ); ?>

    ); ?>
"_mcePaste" >
>
"_mcePaste" >
  • "calendar" >

    'Календарь' ); ?>

  • ); ?>

Save and refresh the window. Here is the result:

WORDPRESS 14. Search field and calendar.

What is going on ?

  • < li id = " calendar "> - open the list item with the ID, named “calendar”
  • - start subtitle

  • ?> - print the word Calendar
  • - close the subtitle
  • get _ calendar () - call the calendar using the get_calendar () function
  • - close the list item

With the calendar, everything is extremely simple. We assume that we are finished.

Step 3 :

Add Meta. Enter the following code under get_ links_ list () :

?
one
2
3
four
five
6
7

WORDPRESS 14. Search field and calendar.

Save and refresh the window. Here is the result:

WORDPRESS 14. Search field and calendar.

(If you did not go to the WordPress admin panel)

WORDPRESS 14. Search field and calendar.

(If logged in)

What happened?
You have opened a list item ( LI ) with the subtitle ( H2 ) Meta . Under the subtitle you placed an unnumbered list ( UL ). And put around it (for each link) list item tags ( LI ).

The wp_ register () function generates its own set of tags < li> and li> ; when you are not logged in, the Register link is displayed; when you are logged in, you see the Site Admin link. The wp_ loginout () function does not generate its list item tags, so you put them around it; when you are not logged in, you see the Login link; when logged in, a Logout link. So far, the wp_ meta () function does nothing; it is invisible both on the webpage and in the source code. Don't think about the wp_ meta () function yet ; you will rarely use it.

It's all. We ended up with Meta and fully reviewed the standard sidebar.


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)