使用WordPress构建非博客网站

tech2022-08-16  145

This post digs into how you can use WordPress to run a regular, non-blog website.

这篇文章深入探讨了如何使用WordPress来运行常规的非博客网站。

WordPress began as a blogging platform and has a long-established dominance in the world of blogging. No matter what kind of blog you’re intending to run, WordPress can help you get it done with ease.

WordPress最初是一个博客平台,在博客世界中具有悠久的统治地位。 无论您打算运行哪种博客,WordPress都可以帮助您轻松完成它。

Be it a photo blog, a video blog or even a simple journal for your thoughts, WordPress comes loaded with all the bells, whistles and features that a blogger might ask for!

不管是照片博客,视频博客,还是您想写的简单日记,WordPress都包含了博客可能会要求的所有铃声,口哨声和功能!

With that said, we can also use WordPress for creating a non-blog site — one that doesn’t really need a blog at all, but instead, is just a simple and straightforward website. Despite being primarily a blogging tool, WordPress can very well be made to run a non-blog website.

话虽如此,我们也可以使用WordPress创建一个非博客网站-一个根本不需要博客的网站,而只是一个简单明了的网站。 尽管主要是博客工具,但可以很好地使WordPress运行非博客网站。

WordPress:博客功能 (WordPress: Blogging Features)

WordPress comes with a large array of blogging-specific features out of the box. These include, but are not limited to, things such as comments, blog posts, categories and tags, etc.

WordPress开箱即用地具有大量特定于博客的功能。 这些包括但不限于评论,博客文章,类别和标签等。

Now, it’s obvious that most of these features are vital for running and managing a blog site. However, when building a non-blog site, a good number of such features may not prove useful. We can, obviously, choose to leave them as they are.

现在,很明显,这些功能中的大多数对于运行和管理博客站点至关重要。 但是,在构建非博客站点时,可能无法证明很多此类功能有用。 显然,我们可以选择保留原样。

But what about things on the front end? If we’re totally doing away with the blog posts, won’t blog archives give a “no posts found” message to users? What about the “Uncategorized” category? Such taxonomies too tend to have archives of their own.

但是前端的东西呢? 如果我们完全取消了博客文章,那么博客档案馆不会向用户显示“找不到文章”消息吗? 那“未分类”类别呢? 这样的分类法也倾向于拥有自己的档案。

The easiest way to fix this is to disable the archives altogether. Beyond that, we can also choose to disable many other blog-focused features.

解决此问题的最简单方法是完全禁用存档。 除此之外,我们还可以选择禁用许多其他针对博客的功能。

整合非博客WordPress网站 (Putting Together a Non-blog WordPress Website)

Before going any further, let’s just face the truth: WordPress, in its current shape and form, expects its users to write and publish posts. If all you’re hoping to do is build a static site with a given number of pages, and have no requirement of publishing or regularly updating posts and other forms of content, the blogging sections are redundant.

在更进一步之前,让我们面对一个事实:WordPress以其当前的形状和形式,期望其用户编写和发布帖子。 如果您只想建立一个具有给定页面数的静态站点,而又不需要发布或定期更新帖子和其他形式的内容,那么Blog部分是多余的。

Thus, it’s essential for us to tell WordPress that we don’t need the default post archives, taxonomy or author archives, and so on. The following code, for example, helps you remove all default blog pages and archives from your site:

因此,对我们来说,告诉WordPress我们不需要默认的后期存档,分类法或作者存档等非常重要。 例如,以下代码可帮助您从站点中删除所有默认博客页面和存档:

/* Registering redirect action callback */ add_action('template_redirect', 'sp_remove_blog'); /* Removing blog from our site */ function sp_remove_blog(){ //Works on archive template, single post template or index if( is_archive() || is_single() || is_home() ) { global $wp_query; $wp_query->set_404(); //404 not found } }

The code above disables all blog archives, single post templates as well as blog index templates. Now, WordPress will redirect users from single post templates or blog archives to a 404 page. You can further set custom redirects in your .htaccess file, via a WordPress plugin, or in the code itself to redirect users to a specific page in lieu of 404 page, even the home page!

上面的代码禁用所有博客存档,单个帖子模板以及博客索引模板。 现在,WordPress将用户从单个帖子模板或博客存档重定向到404页。 您可以通过WordPress插件在.htaccess文件中或在代码本身中进一步设置自定义重定向,以代替404页面(甚至是首页)将用户重定向到特定页面!

The above code should ideally be placed in the functions.php file of your theme or child theme. This step is necessary to prevent the creation of empty archive pages that may otherwise hurt your search rank. With that said, you can also, to some extent, disable several archives by means of a good SEO plugin, such as Yoast SEO (refer to plugin-specific documentation for detailed guidelines related to the same).

理想情况下,以上代码应放在您的主题或子主题的functions.php文件中。 必须执行此步骤,以防止创建空的存档页面,否则可能会损害搜索排名。 话虽如此,您还可以在某种程度上通过良好的SEO插件(例如Yoast SEO)禁用多个存档(请参阅特定于插件的文档以获取与此相关的详细指南)。

查找非博客WordPress主题 (Finding a Non-blog WordPress Theme)

There’s no shortage of WordPress themes to choose from. Even for non-blog websites, there are plenty of amazing WordPress themes out there both in free and premium variants.

可以选择许多WordPress主题。 即使对于非博客网站,免费和高级版本中也有很多惊人的WordPress主题。

Now, it goes without saying that you should pick your WordPress theme only from reliable sources. It’s very easy to fall prey to a bad WordPress theme and get your website compromised or hacked with minutes.

现在,不用说,您应该仅从可靠来源中选择WordPress主题。 容易陷入不良的WordPress主题,并在几分钟之内让您的网站受到攻击或被黑,这很容易。

As far as free WordPress themes are concerned, the only place that you should look is the official theme repository. WordPress themes in the repo are quality-tested and generally come with better-quality code. Above everything else, free WordPress themes in the official repository are devoid of malicious code or malware.

至于免费的WordPress主题,您唯一要看的地方就是官方主题库。 回购中的WordPress主题经过了质量测试,并且通常带有质量更高的代码。 最重要的是,官方存储库中的免费WordPress主题没有恶意代码或恶意软件。

For non-blog websites, the official repository has several tags that you can use to shortlist the perfect theme. For example, the “Education” feature filter generally provides themes meant for education-specific sites, but you can use these on virtually any non-blog site. The same applies to the “Holiday” filter as well.

对于非博客网站,官方存储库具有几个标签,您可以使用它们来标记完美的主题。 例如,“ 教育 ”功能过滤器通常提供针对教育特定网站的主题,但是您几乎可以在任何非博客网站上使用这些主题。 “假日”过滤器也是如此。

When selecting a premium WordPress theme, make sure you opt for a reputed theme seller. Furthermore, the tags or genres of themes that you should focus on are commonly termed as “Business” or “Corporate” WordPress themes. Most such themes tend to come with a custom blog page template or layout, which should not be much of a worry as you would have disabled the archive page display using the above code anyway.

选择高级WordPress主题时,请确保选择知名的主题卖家。 此外,您应重点关注的主题标签或类型通常被称为“商业”或“公司” WordPress主题。 大多数此类主题通常都带有自定义博客页面模板或布局,因此不必担心,因为无论如何您都将使用上述代码禁用存档页面的显示。

However, there is one particular step of caution that you should take when picking a WordPress theme for your non-blog website. By all means, avoid WordPress themes that come loaded with a heavy range of “custom” features, especially ones with custom shortcodes, custom buttons, custom page templates, and so on. Such WordPress themes tend to work out of the box only when you’re using WordPress the way it’s supposed to be. When you’re attempting to build a truly non-blog website in WordPress, the custom page templates and shortcodes can only get in the way. What will you do with a grid archive blog page template when you do not have blog posts to display in the first place?

但是,在为非博客网站选择WordPress主题时,应采取一个特别的警告步骤。 无论如何,避免使用带有大量“自定义”功能的WordPress主题,尤其是那些带有自定义短代码,自定义按钮,自定义页面模板等的主题。 仅当您以预期的方式使用WordPress时,此类WordPress主题才易于使用。 当您尝试在WordPress中构建真正的非博客网站时,自定义页面模板和简码只会妨碍您的操作。 当您没有首先显示的博客文章时,您将如何处理网格归档博客页面模板?

Certain premium WordPress themes, such as Divi by Elegant Themes, are an exception to the above rule, as these themes tend to have an ecosystem and pre-made templates of their own. You can, in fact, select a Business template in Divi and have a non-blog site imported to your WordPress installation in no time! But for the most part, it’s preferable to use a series of WordPress plugins to achieve such customized functionality. Speaking of WordPress plugins …

某些高级WordPress主题(例如Divi by Elegant Themes )是上述规则的例外,因为这些主题往往具有自己的生态系统和预制模板。 实际上,您可以在Divi中选择一个业务模板,并立即将一个非博客网站导入到您的WordPress安装中! 但在大多数情况下,最好使用一系列WordPress插件来实现此类自定义功能。 说到WordPress插件…

用于构建非博客网站的WordPress插件 (WordPress Plugins for Building Non-Blog Websites)

Nowadays, it’s become a norm to turn towards WordPress plugins for extending and getting more out of WordPress. With such a large range of WordPress plugins at our disposal, it’s only natural to make use of some useful plugins to further improve our site.

如今,转向WordPress插件以扩展和从WordPress中获取更多信息已成为一种规范。 由于我们拥有大量的WordPress插件,因此很自然地利用一些有用的插件来进一步改善我们的网站。

While the common nature of WordPress plugins — such as those for SEO or security — tend to remain the same for both blogging and non-blogging sites, we can employ a couple specialized WordPress plugins that are specifically meant for non-blogging projects.

尽管WordPress插件的通用性(例如用于SEO或安全性的插件)在博客和非博客网站上都保持不变,但我们可以使用几个专门用于非博客项目的专用WordPress插件。

To begin with, the Disable Comments WordPress plugin can help you disable comments globally on your site. This means all instances of comment management and moderation, as well as comment forms on the front end, are eliminated from your non-blog site. Not only can this ensure that you don’t have to deal with spam anymore, but the Disable Comments plugin can also de-clutter your WordPress admin panel by removing the comment-related items from WordPress Dashboard, admin menu, admin panel, etc.

首先, Disable Comments WordPress插件可以帮助您全局禁用站点上的评论。 这意味着从您的非博客站点中删除了所有评论管理和审核实例以及前端的评论表单。 这不仅可以确保您不再需要处理垃圾邮件,而且“禁用评论”插件还可以通过从WordPress仪表板,管理菜单,管理面板等中删除与评论相关的项目来整理WordPress管理面板。

Next, the Google XML Sitemaps plugin can prove useful for non-blog sites as well. As the name suggests, this particular plugin helps you create and manage your sitemaps more efficiently. It’s recommended that you use a dedicated sitemaps plugin, because there will be several aspects of your site that you would not want to include in your sitemap — particularly ones related to blogging, such as taxonomy archives. Using a specialized sitemaps or SEO plugin can help you ensure search engines are not crawling any unwanted section of you non-blog website.

接下来, Google XML Sitemaps插件对于非博客网站也很有用。 顾名思义,此特定插件可帮助您更有效地创建和管理站点地图。 建议您使用专用的站点地图插件,因为您不想在站点地图中包含网站的多个方面,尤其是与博客相关的方面,例如分类档案。 使用专门的站点地图或SEO插件可以帮助您确保搜索引擎不会抓取您非博客网站的任何不需要的部分。

在非博客网站上管理内容 (Managing Content on a Non-blog Website)

Now, at this stage you’ve installed some useful WordPress plugins and also eliminated blogging-specific features from your WordPress installation.

现在,在此阶段,您已经安装了一些有用的WordPress插件,并且还从WordPress安装中删除了特定于博客的功能。

You’ve also shortlisted a good WordPress theme that suits the needs and requirements of your non-blog site.

您还选择了一个适合您非博客网站需求的好WordPress主题。

Naturally, it’s time to get things started. Generally, for a non-blog site, you’ll mostly be working with pages. Depending on your site’s needs, you may add as many pages as necessary. However, there’s generally a three-step model to follow.

自然,是时候开始了。 通常,对于非博客网站,您通常会使用页面。 根据您站点的需要,您可以根据需要添加任意数量的页面。 但是,通常需要遵循三个步骤的模型。

The first step, obviously, is to add a custom home page. You can navigate to your site’s Reading submenu under the Settings menu, and then specify a custom home page therein. Often, the WordPress theme that you choose will have a custom home page template that you can use on the given page.

显然,第一步是添加自定义主页。 您可以导航到“设置”菜单下站点的“阅读”子菜单,然后在其中指定自定义主页。 通常,您选择的WordPress主题将具有可在给定页面上使用的自定义主页模板。

The second step is to add the required pages to your site and build your content. Since the Pages post type in WordPress doesn’t have categories or tags associated with it as taxonomies, you can simply place your content and perhaps specify a hierarchy if needed, in the form of child pages. It might be a good idea to make use of a page builder plugin at this point.

第二步是将所需的页面添加到您的站点并构建您的内容。 由于WordPress中的Pages帖子类型没有作为分类法与之关联的类别或标签,因此您可以简单地放置您的内容,并在需要时以子页面的形式指定层次结构。 此时,最好使用页面构建器插件。

Elementor, for example, comes with a preset range of elements that you can add to your pages’ content and give your website a more unique look.

例如, Elementor附带了一系列预设元素,您可以将它们添加到页面的内容中,并为您的网站提供更独特的外观。

Finally, you can also add custom post types to your site. For example, testimonials and other custom elements can be shown as custom post types. Jetpack, the popular WordPress plugin, comes with Testimonial and Portfolio post types, though for more complex post types you can make use of a plugin such as Custom Post Type UI.

最后,您还可以将自定义帖子类型添加到您的网站。 例如,推荐和其他自定义元素可以显示为自定义帖子类型。 Jetpack是流行的WordPress插件,带有见证和投资组合帖子类型,但是对于更复杂的帖子类型,您可以使用自定义帖子类型UI等插件。

摘要 (Summary)

So there you have it! It’s fairly easy to build a non-blog website in WordPress and the entire process can be accomplished in simple steps. All that’s needed is to disable the blogging-specific features and then turn towards WordPress pages (and, if required, custom post types), and get the job done!

所以你有它! 在WordPress中建立非博客网站非常容易,整个过程可以通过简单的步骤完成。 所有需要做的就是禁用特定于博客的功能,然后转到WordPress页面(如果需要,还可以自定义帖子类型),然后完成工作!

WordPress is the world’s most popular content management system. Naturally, it goes without saying that it can, and does, very effectively empower both blogging and non-blogging websites. As a result, WordPress is a good choice for building non-blog sites, and if you’re planning to build one anytime soon, you should consider giving WordPress a spin!

WordPress是世界上最受欢迎的内容管理系统。 自然,不用说,它可以而且确实非常有效地增强了博客和非博客网站的功能。 因此,WordPress是构建非博客网站的理想选择,如果您打算尽快构建一个非博客网站,则应考虑让WordPress旋转!

翻译自: https://www.sitepoint.com/wordpress-non-blog-site/

相关资源:博客:with用Wordpress和Gatsby构建的博客网站-源码
最新回复(0)