简体   繁体   English

WP边栏小部件未显示正确的文本

[英]WP Sidebar Widget not showing correct text

I'm working on my next Wordpress website for a customer (it's still on localhost so I can't give you a link). 我正在为客户在下一个Wordpress网站上工作(它仍在localhost上,所以我不能给您链接)。 I got 4 pages and I need 2 sidebars. 我有4页,我需要2个侧边栏。 So I paste a code into functions.php for creating 2 sidebars: 因此,我将代码粘贴到functions.php以创建2个侧边栏:

<?php
    if ( function_exists('register_sidebar') ) 
        {
            register_sidebar(array('name' => 'Angebot'));
            register_sidebar(array('name' => 'Anfahrt'));
        }
?>

In the backend, the 2 sidebars are shown correctly and I can put some text into (I just put some random text for test in the sidebars and nothing else). 在后端中,正确显示了2个侧边栏,我可以在其中添加一些文本(我只是在侧边栏中放了一些随机文本进行测试,其他什么也没有)。 And then I put some code into index.php and into page.php : 然后我将一些代码放入index.phppage.php

<div id="sidebar">        <?php if(is_page('Willkommen') || is_page('Angebot'))
            {
                get_sidebar('Angebot');
            }

            else
            {
                echo "Huhu";
            }
        ?>
    </div><!-- sidebar -->

I put the text "Huhu" in the else that I can see if the code works. 我在其他代码中添加了文本“ Huhu”,以查看代码是否有效。 And it does. 确实如此。

But my problem now is: It takes the sidebar I told it in my code but it doesn't show my text I put into the widget sidebar. 但是现在我的问题是:它需要我在代码中告诉过的侧边栏,但没有显示我放入小部件侧边栏中的文本。 It just show the archive , categories , pages etc. And I still don't know why. 它只显示archivecategoriespages等。我仍然不知道为什么。

Has someone an idea or can someone give me a hint? 有一个想法或可以给我一个提示吗?

Thanks in advance 提前致谢

Cheers 干杯

Try replacing this:- 尝试更换它:-

get_sidebar('Angebot');

with this:- 有了这个:-

dynamic_sidebar('Angebot');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM