How to display sidebar in wordpress mobile station

Call the sidebar is sidebar.php and the footer is footer.php!

Whether it's index.php on the homepage or single.php on a single log page, there are always two lines of code at the end of the file:

& lt? PHP get _ sidebar(); ? & gt

& lt? PHP get _ footer(); ? & gt

We need to explain it in two situations:

The first case: If you don't use theme widgets, you can call different sidebars in only two steps.

Find the single.php file:

& lt? PHP get _ sidebar(); ? & gt

Revised as:

& lt? PHP include _ once(" sidebar 2 . PHP "); ? & gt

Upload and overwrite single.php, refresh, done!

In the second case, if widgets are used, it takes only 4 steps to call different sidebars.

Repeat the steps for creating a new sidebar2.php in the first case.

Then open function.php and find a similar code:

& lt? Server-side programming language (abbreviation of professional hypertext preprocessor)

if(function _ exists(' register _ sidebar '))

Register_sidebar (array (

before _ widget ' = & gt'',

after _ widget ' = & gt,

before _ title ' = & gt'

));

These lines of code are an "application", applying for a widget from Wordpress. If you want to display different sidebar on different surfaces, and this sidebar supports widgets, you need to write an "application" to Wordpress to apply for a widget. Moreover, this application has a name, and the name format should be written as follows:'' name' =>' Name', which should be consistent with the names of some widgets called by sidebar2.php later, so it should be written as follows:

if(function _ exists(' register _ sidebar '))

Register_sidebar (array (

Name' => Sidebar 2',

before _ widget ' = & gt& ltid = " % 1 $ s " class = " widget % 2 $ s " > ",

after _ widget ' = & gt,

before _ title ' = & gt'

,

' after _ title ' = & gt'

,

));

Add the above sentence to the original "application" Now, you need to change the code that originally called the default widget in sidebar2.php to call sidebar2, which is a widget of a new application. Open Sidebar2.php and find this code:

& lt? PHP if(function _ exists(' dynamic _ sidebar ')& amp; & ampdynamic_sidebar() ) : else:? & gt

& lt? php endif? & gt

Revised as:

& lt? PHP if(function _ exists(' dynamic _ sidebar ')& amp; & ampdynamic _ sidebar(sidebar 2)):else:? & gt

& lt? php endif? & gt

Now do the last job, open the single.php and find:

& lt? PHP get _ sidebar(); ? & gt

Revised as:

& lt? PHP include _ once(" sidebar 2 . PHP "); ? & gt

Save the file and upload it.

Now, if you go to the Widgets settings in the background, you will find that there is one more Widget in the drop-down list. Its name is Sidebar2, and now you need to add something to it.

Summarize the general steps of the second case:

* Apply for a Widgets in functions.php.

* Call sidebar2.php in single.php.

* modify the widgets called in sidebar2.php to the sidebar.

* Drag your widget.

At this point, we have completed the tutorial of displaying different sidebars on different pages!