许多WordPress主题都使用默认的侧边栏构建。侧边栏是一个区域,该区域在主内容空间的左侧,右侧或下方显示信息。

Depending on your WordPress website, your sidebar may include social media feeds, recent blog posts, or advertisements. However, sidebars aren’t always necessary for a particular page (or your entire website). Let’s explore how to remove sidebars on yourWordPress网站.

使用HubSpot的WordPress网站来发展业务

为什么要从WordPress网站上删除侧边栏?

侧边栏是一个宝贵的空间在你的网站上。You can showcase related content to your visitors, like popular ebooks, your latest podcast episodes, or an email sign-up form. Many businesses find the sidebar useful for engaging their potential customers.

But the sidebar isn’t helpful for every website experience. For example, visitors landing on your website on their mobile devices may find it difficult to view your sidebar content due to the reduced screen size. You don’t want your visitors constantly放大智能手机只是与您的网站互动。

如果侧边栏未进行战略性放置,则可以分散访问者的注意力。您不想将访客带到一个永无止境的侧边栏内容的兔子洞,因为它可能会降低转换率。

So, if you’re ready to ditch the sidebar (even if it's only temporarily), continue reading.

删除侧边栏的过程将根据您的WordPress主题而有所不同。我们将首先从最简单的方法开始。

卸下WordPress仪表板中的侧边栏

  • 登录您的WordPress仪表板。
  • Go to外貌>小部件on the left side of your dashboard.
  • 找到侧边区域。看起来与此相似:

sidebar area for how to remove sidebar in WordPress - find the sidebar area

  • Expand the widget section by clicking the down arrow.
  • 然后,单击删除.

delete widgets for how to remove sidebar in WordPress - delete the widget

  • 重复这些步骤,直到您删除了侧边栏区域下方的所有小部件。

Remove Sidebar Using a Plugin

WordPress plugins make it simple to add features to your website. You can install a plugin to remove the sidebar on your website, too. Follow the steps below.

  • Go to插件>添新on the left side of your dashboard.
  • Search for the小部件禁用plugin.
  • Install and activate the plugin.

widget disable plugin to delete a sidebar in wordpress

  • Go to外貌>Disable Widgets.
  • Under theSidebar Widgetstab, clickSelect allto disable the sidebar widgets from your website.
    小部件禁用插件 - 禁用网站上的侧栏小部件
  • Click节省Changes.

在FTP中卸下侧边栏

If you feel comfortable editing the code in your theme, then you can remove the sidebar using an FTP client. Before implementing this method, we recommend backing up your website and using a儿童主题to prevent losing any important changes.

  • 连接到您的FTP。
  • Open the folder:/wp-content/themes/your-current-theme/
  • 您应该查看所有模板文件。(例如,home.php,index.php,single.php,archive.php和page.php)
  • To remove the sidebar, delete this line of code from each template:

  • 您的WordPress主题可能具有多个侧边栏。因此,查找类似的代码并将其删除:

  • Click节省完成从每个模板中删除所有代码后。

You can view the changes on your website now. If you’re using a caching plugin, be sure to deactivate it to see your changes. You can always reactivate the caching plugin later.

Removing Sidebar from Static Page

也许您只想从特定页面中删除侧边栏,而不是从整个网站上删除。静态页面是一个自定义页面,当您将博客文章添加到网站上时不会更改。大多数企业使用静态页面作为主页。要将这些更改为静态页面,您需要更新模板。

在WordPress仪表板中更改模板

新的WordPress主题配备了没有侧边栏的全宽模板。您可以将这些模板用作网站上的静态页面。切换模板只需几分钟。

  • Go to页面on the left side of your dashboard.
  • 选择所需的静态页面。
  • 在right-hand side, find页面属性.
  • Under模板, select全屏宽度.

更改页面属性部分下的WordPress仪表板中的模板,然后从下拉列表中选择完整的宽度

  • 单击蓝色发布或者更新按钮。

Change Template in FTP

If this option doesn’t appear in your settings, you can create your own full-width page template.

  • Open any text editor and create a new file.
  • Name the filefull-width.php并将其保存在您的桌面上。
  • Connect to your hosting account using an FTP client.
  • Locate the folder:/wp-content/themes/your-theme
  • Selectpage.php文件and edit it.
  • 复制此文件中的所有代码并将其粘贴到您的full-width.php file.
  • 开幕之后标签add this code:

/*

模板名称:全宽

*/

  • 在里面full-width.php文件, 寻找 :
  • 删除这条代码线是因为它生成侧边栏。
  • 节省the changes.
  • Upload style="font-weight: bold;">full-width.php file to your child theme folder via your FTP client.
  • When you go to页面属性,您现在应该查看“全宽页”模板选项。

Remove Sidebar from Blog Post Page

You’ll notice that many WordPress themes display sidebars on the blog posts page, too. But don’t worry, you can remove them.

  • Go to设置>Readingon the left side of your dashboard.
  • Next to您的主页显示, 去帖子page.
  • 从上一节中的示例中选择无侧栏的静态页面模板。

主页显示如何从主页显示部分中的博客文章页面中删除WordPress中的侧边栏

如果没有可用侧栏的模板,请阅读上一节,然后按照说明手动创建全宽模板。

Remove Sidebar from a Single Post

If you don’t want to remove sidebars from all of your blog posts, you can customize a single post to have no sidebar.

  • Go to帖子on the left side of your dashboard.
  • 选择所需的博客文章。
  • 在right-hand side, findPost Attributes.
  • Under模板, select全屏宽度.

post attributes for how to remove sidebar from a single post in WordPress - select full width under post attributes

  • 单击蓝色发布或者更新按钮。

If you can’t find the full-width option, you can create a custom page template without sidebars. The steps are similar to changing a template for a static page. The only difference is that you will need to copy and edit the single.php file.

Sidebar or No Sidebar?

Sidebars are helpful for displaying relevant content to visitors, but sometimes you need to remove them to improve your website’s overall appearance, improve conversion rates, or make a page easier to navigate. With each of these options to remove a sidebar, you can customize your website to appear and function exactly the way you want.

编者注:该帖子最初于2019年9月发表,并已更新以进行全面性。

使用WordPress网站上的HubSpot工具,并在不处理代码的情况下连接两个平台。点击这里了解更多。

使用WordPress网站上的HubSpot工具,并在不处理代码的情况下连接两个平台。点击这里了解更多。

Originally published Mar 17, 2021 7:00:00 AM, updated March 17 2021

Topics:

WordPress Website