php 如何编辑 WordPress 网站的代码?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6967784/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I edit the code of a WordPress site?
提问by Eric Thoma
I am helping out a family member with their WordPress blog and he/she wanted to have the comments show on the main front page. This way, users don't have to click through the title to add a comment. If that is impossible, he/she wanted to have instructions like "click here to add a comment" near the title.
我正在帮助一位家庭成员使用他们的 WordPress 博客,他/她希望在首页上显示评论。这样,用户不必单击标题即可添加评论。如果这是不可能的,他/她希望在标题附近有诸如“单击此处添加评论”之类的说明。
I know how to write html/css etc., so I would just go in and type in some code but I don't have an FTP account. Is there a way to edit the html of a WordPress site through the WordPress Dashboard menu thing? I would ask for a FTP account, but I doubt he/she knows how to create one. Also, would doing this really screw things up for WordPress? Any and all help is appreciated. If needed I can give the URL, but I would rather not have people trying to post comments and mess around with the site. Thanks!
我知道如何编写 html/css 等,所以我只需要输入一些代码,但我没有 FTP 帐户。有没有办法通过 WordPress 仪表板菜单来编辑 WordPress 网站的 html?我会要求一个 FTP 帐户,但我怀疑他/她知道如何创建一个。另外,这样做真的会让 WordPress 搞砸吗?任何和所有的帮助表示赞赏。如果需要,我可以提供 URL,但我宁愿没有人试图发表评论并在网站上乱搞。谢谢!
回答by laurent
The easiest way is indeed to have an FTP access and edit the blog's theme directly (in /wp-content/themes/nameofyourtheme
. Otherwise, you can also do it from the Admin panel. Go to Appearance, then click on "Editor". You'll then be able to edit all the theme's files.
最简单的方法确实是拥有 FTP 访问权限并直接编辑博客的主题(在/wp-content/themes/nameofyourtheme
.所有主题的文件。
Edit:
编辑:
If you want to change the layout of the posts, the file you'll want to edit is single.php
.
如果您想更改帖子的布局,您需要编辑的文件是single.php
.
回答by Eric Thoma
You can edit the site through the dashboard. When you are making a post you can change it to html and create your own things.
您可以通过仪表板编辑站点。当您发布帖子时,您可以将其更改为 html 并创建您自己的内容。
回答by Joonas
Unless there is a plugin for this. Which there might even be. But, since i have no idea and fast googling said nothing.
除非有这个插件。甚至可能有。但是,由于我不知道并且快速谷歌搜索什么也没说。
You will have to edit the theme files /wp-content/themes/Your-Theme/
您将不得不编辑主题文件 /wp-content/themes/Your-Theme/
You will have to take something like <?php comments_template(); ?>
from single.php
file and move it to index.php file somewhere after where you should find something like this <?php the_content(''); ?>
你将不得不<?php comments_template(); ?>
从single.php
文件中取出类似的东西,然后将它移动到 index.php 文件的某个地方,然后你应该找到这样的东西<?php the_content(''); ?>
single.php
Holds the article page.index.php
Holds the "home" page.
single.php
持有文章页面。index.php
持有“主页”页面。
Is this hosted in wordpress.com?
这是在 wordpress.com 中托管的吗?
In the control panel you can find Appearance > editorin there you can edit the files. Thought i think that it is very likely that you wont be able to save your edits due to file permissions.
在控制面板中,您可以找到外观 > 编辑器,您可以在其中编辑文件。我认为我认为由于文件权限,您很可能无法保存您的编辑。
Also if its a paid hosting they quite often send you these details on email.. I mean Ftp acc and pass.
此外,如果它是付费托管,他们经常通过电子邮件向您发送这些详细信息。我的意思是 Ftp acc 并通过。