How can I move the WordPress toolbar CODE to the top of the page?

时间:2016-02-12 20:08:53

标签: wordpress

Before anyone says this may be a duplicate, I don't want to move the toolbar to the bottom of the page with css. I have a layout that is being fudged up by the toolbar. The toolbar is covering the top of my banner. I want to move the code for the toolbar from the bottom of the HTML to the top and then change the position to relative instead of fixed. This way the toolbar will push all the content after it down instead of covering up the content. How can I do this?

2 个答案:

答案 0 :(得分:0)

The top bar often seems to do this. Why not just get rid of it? That's what I usually do.

In functions.php add the following:

The value expression for the textrun 'Textbox23.Paragraphs[8].TextRuns[1]' contains an error: [BC30201] Expression expected.

答案 1 :(得分:0)

首先,您需要将其添加到functions.php文件中,以便不再在wp_footer操作上呈现管理栏:

remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 );

执行此操作后,只需在打开header.php标记后立即将其添加到<body>文件中:

<?php wp_admin_bar_render(); ?>

同时在同一文件中找到开始<html>标记,然后添加class="html_class"。这将允许我们覆盖WordPress添加到html元素的margin-top。

然后编写使管理栏保持静止所需的CSS:

#wpadminbar {
    position: relative !important;
}
html.html_class {
    margin-top: 0 !important;
}