使用 WordPress 作为 CMS
我目前正在自学 WordPress 并开发自己的 CMS 网站。
我的网站将由大约五个页面组成,其中页眉/侧边栏菜单/页脚将在所有这五个页面上看到。
初学者,问题如下:
这五个页面都会包含不同的内容,例如,每个页面都会有一个图像横幅代表刚刚单击的菜单选项,例如第 5 页的“关于我们”,“促销”在第 4 页等,然后是下面的一些文本,然后可能是轮播设置内的一些图像。
在 WordPress 中,我将如何解决这个问题,即我只是在 WordPress 中创建一个页面,将横幅图像放置在页面顶部,然后进行一些休息,然后插入图像轮播 - 这是正确的吗?
如果没有,我是否需要创建一个名为 aboutUs.php 的单独 php 文件,其中包含此标记,然后以某种方式将其链接到 WordPress 页面?
仅在我网站的登陆页面(第 1 页)页脚上方,我想显示一个 div 部分,其中显示网站的所有赞助商以及单击其网站的 URL - 我该怎么做关于在 WordPress 中执行此操作吗?
此外,通过我的菜单,我如何链接我的菜单以指向与该菜单选项相关的 WordPress 页面?
I am currently teaching myself WordPress and working on my own CMS site.
My site will consist of approximately five pages where the header/sidebar menu/footer will be seen on all these five pages.
Beginner here and questions are as follows:
All these five pages will consist of different content, for example, every page will have a image banner representing the menu option just clicked, for example, "About Us" on page 5, "Promotions" on page 4 etc and then some text beneath that and then possibly some images inside a carousel set up.
Within WordPress, how would I tackle this, i.e. do I just create a page in WordPress, position the banner image at the top of the page, then have a few breaks and then insert the carousel of images - is this correct?
If not, do I need to create a separate php file called aboutUs.php that has this markup and then somehow link it to a WordPress page?
On my landing page of my site ONLY (page 1), just above the footer, I want to display a div section that displays all the sponsors of the website along with a URL to click to their websites - how would I go about doing this in WordPress?
Furthermore, with my menu, how do I link my menus to point to the WordPress pages relating to that menu option?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您使用 WordPress 附带的“默认”模板,您可以执行类似的操作,在不同页面上生成不同的内容,而无需创建单独的 php 文件(这将放在 page.php 中):
本质上,您可以在其中创建一个帖子和一个“关于我们”类别来引用它。 “关于我们”页面(通过 is_page() 引用)将包含您想要显示的内容。
If you use the 'default' template that comes with WordPress you could do something like this to generate different content on different pages without creating separate php files (this would go in page.php):
Essentially, in this you could just create a post and an 'aboutus' category to reference it. The page of 'About Us' (referenced through is_page()) would contain the content you wanted to display.
首先,一些背景知识。 Wordpress 有多种显示内容的方式,例如图像、文本和查询结果;这里有一个列表:
主题
您可以直接修改主题文件以执行您喜欢的任何操作。这可能需要学习很多有关 PHP 和 Wordpress 内部结构的知识,但是有很多书籍,以及 Wordpress Codex 来帮助你。您可以从 WordPress 主题目录 获取主题。
插件
Wordpress 插件数量众多,其中任何一个都可能适合您的需求。插件需要配置,但通常不需要学习 PHP——只需要学习如何安装和配置它们。大多数 SEO(搜索引擎优化)插件允许您在模板中放置自定义 HTML(名义上用于广告放置,但您可以用它做任何您想做的事情)。您可以从 Wordpress 插件目录获取插件。
小部件
基本的 WordPress 软件和许多插件提供小部件。 小部件是一种可以停靠在一个或多个小部件区域中的显示元素。通常,小部件是应用了主题样式表的 HTML 块(通常是无序列表)。小部件通常用于广告投放、导航元素(菜单、下拉菜单、面包屑)或提供标签云、类别列表、日历等。
SHORTCODE
A shortcode 是一个可以放置在页面或帖子中的宏,它将返回 HTML 块。短代码可以采用会影响短代码返回内容的参数。基本的 Wordpress 软件提供了一些短代码,但许多插件将提供短代码作为一种无需小部件或主题修改即可获得更多功能的方式。
考虑到所有这些,这是我对您的问题的回答:
First, some background. Wordpress has a number of ways to display stuff, such as images, text, and query results; here's a list:
THEMES
You can modify your theme files directly to do whatever you like. This will probably involve learning a lot about PHP and the Wordpress internals, but there are plenty of books, and the Wordpress Codex to help you. You can get themes from the Wordpress theme directory.
PLUGINS
There are huge numbers of Wordpress plugins, any one of which might fit your need. Plugins will require configuration, but generally won't involve learning PHP -- just how to install and configure them. Most of the SEO (Search Engine Optimization) plugins will allow you to place custom HTML in the templates (nominally for ad placement, but you can do anything you want with it). You can get plugins from the Wordpress plugin directory.
WIDGETS
The base Wordpress software and many plugins provide Widgets. A widget is a display element that can be docked in one or more widget areas. Typically a widget will be a chunk of HTML (often an unordered list) that has the theme's style sheet applied. Widgets are often used for ad placement, navigation elements (menus, dropdowns, breadcrumbs) or to provide tag clouds, category lists, calendars, etc.
SHORTCODE
A shortcode is a macro that can be placed in a page or post, that will return a chunk of HTML. Shortcodes can take parameters that will affect what the shortcode returns. The base Wordpress software provides some shortcodes, but many plugins will provide shortcodes as a way to get more functionality without the need for widgets or theme modifications.
With all of that in mind, here's my answer(s) to your question(s):
查看 WordPress“页面模板”。 Wordpress 法典可以帮助您理解这一点。
如果您在 WP 中编辑帖子,您会注意到使用模板的选项。这就是你的目标。了解如何与他们合作。
Look into Wordpress "page templates". The Wordpress codex can help you understand this.
If you edit a post in WP you will notice the option to use a template. That is your goal. Learn how to work with them.
Wordpress 主题由多个文件组成。其中之一是包含标头内容的
header.php
文件。footer.php
文件包含页脚,sidebar.php
文件包含侧边栏。这些是通常的约定。他们并不严格。将有几个包含这些的main文件(例如,index.php
- 用于文章,page.php
- 用于显示页面等)如果我进行像您这样的设置,我会创建五个“页面”(使用后端),然后自定义我的
page.php
文件以正确呈现它。我仍然会将页眉、页脚和侧边栏与page.php
文件分开,因为它们也会出现在 404 等页面中。只需在登陆页面的内容中添加一些内容即可显示此内容。
如果您正在进行主题开发,则正确的查看位置是 http://codex.wordpress.org/Theme_Development
Wordpress themes are composed of multiple files. One of them is the
header.php
file which contains the header content. Thefooter.php
file contains the footer and thesidebar.php
contains the sidebar. These are the usual conventions. They're not strict. There will be a couple of main files which include these (e.g.,index.php
- Used for articles,page.php
- Used to display pages etc.)If I were making a setup like yours, I'd make five "pages" (using the backend) and then customise my
page.php
file to present it properly. I'd still keep the header, footer and sidebar separate from thepage.php
file since they'd be there for pages like 404s etc. as well.Just put something in the content of the landing page to display this.
IF you're doing theme development, the right place to look at is http://codex.wordpress.org/Theme_Development