php 如何在wordpress主题中编辑html代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37045111/
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 to edit the html code in wordpress theme
提问by tomer
I have a wordpress blog and I want to customize it a bit. I know CSS and HTML but not php. from what I understood the php should call the html code, so if i could find the html code it will be easy for me to customize my blog.
我有一个 wordpress 博客,我想对其进行一些自定义。我知道 CSS 和 HTML 但不知道 php。根据我的理解,php 应该调用 html 代码,所以如果我能找到 html 代码,我将很容易定制我的博客。
The thing is, I can't find the html code. I looked at appearance --> editor and it is all php files and one css.
问题是,我找不到 html 代码。我看了看外观 --> 编辑器,它是所有 php 文件和一个 css。
Someone has an idea how to edit the html code/find it ?
有人知道如何编辑 html 代码/找到它吗?
thanks
谢谢
回答by naveenkumar.s
If you want to edit your wordpress theme html , css etc. Kindly follow the steps.
如果你想编辑你的 wordpress 主题 html、css 等,请按照步骤操作。
Always use a child theme
始终使用子主题
Before you start editing your WordPress theme create a child theme. Child themes are important, because they protect your original theme files.
在开始编辑 WordPress 主题之前,创建一个子主题。子主题很重要,因为它们可以保护您的原始主题文件。
Appearance → Themes->your child theme-> activate
Edit WordPress theme HTML
编辑 WordPress 主题 HTML
Go to Appearance → Editorin your WordPress dashboard and choose the child theme you have activated.
转到 WordPress 仪表板中的外观 → 编辑器,然后选择您已激活的子主题。
There are index.php, functions.php, header.php, footer.php etc.
有 index.php、functions.php、header.php、footer.php 等。
In its most basic form, PHP is grabbing content from your WordPress site and outputting it in an HTML page. Take a look at this section of code specifically:
在最基本的形式中,PHP 从您的 WordPress 站点获取内容并将其输出到 HTML 页面中。具体看一下这一段代码:
<div class="site-info">
<?php do_action( 'twentyfourteen_credits' ); ?>
<a href="<?php echo esc_url( __( 'http://wordpress.org/', 'twentyfourteen' ) ); ?>"><?php printf( __( 'Proudly powered by %s', 'twentyfourteen' ), 'WordPress' ); ?></a>
</div><!-- .site-info -->
That code translates to this HTML:
该代码转换为以下 HTML:
<div class="site-info">
<a href="http://wordpress.org">Proudly powered by WordPress</a>
</div><!-- .site-info -->
Try to understand like the above codes php and html. you can easily edit it.
试着理解像上面的代码php和html。您可以轻松编辑它。
Edit WordPress theme CSS
编辑 WordPress 主题 CSS
Appearance → Editor->style.css(child theme).
you can change the style of detailed reference click here
您可以更改详细参考的样式单击此处
回答by stalin wesley
Go to your wp-admin, Appearance (on the left sidebar), Editor. Select a theme and a file to edit, then press Save.
转到您的 wp-admin、外观(在左侧边栏上)、编辑器。选择要编辑的主题和文件,然后按保存。
回答by Marco Panichi
In WordPress Dashboard > Appeareance > Editor you can't edit HTML files(only PHP and CSS files) as you can read in Codex - "Editing files"
在 WordPress 仪表板 > 外观 > 编辑器中,您不能像在Codex 中读取的那样编辑 HTML 文件(仅限 PHP 和 CSS 文件)-“编辑文件”
Your question could become why don't you see HTML in PHP files?
您的问题可能会变成为什么在 PHP 文件中看不到 HTML?
This is because PHP generates HTML codeand then you can see lots of PHP code inside a PHP file, but not necessarly HTML code. In order to understand how PHP works I suggest you to read this useful tutorial.
这是因为PHP 生成 HTML 代码,然后您可以在 PHP 文件中看到大量 PHP 代码,但不一定是 HTML 代码。为了理解 PHP 的工作原理,我建议您阅读这个有用的教程。
回答by Owais Alam
Here's a completed page template that utilizes everything described above with additional markup and includes the loop:
这是一个完整的页面模板,它利用上述所有内容和附加标记并包括循环:
<php get_header(); ?>
<div id="content">
<?php query_posts('post_type=post&post_status=publish&posts_per_page=10&paged='. get_query_var('paged')); ?>
<?php if( have_posts() ): ?>
<?php while( have_posts() ): the_post(); ?>
<div id="post-<?php get_the_ID(); ?>" <?php post_class(); ?>>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( array(200,220) ); ?></a>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<span class="meta"><?php author_profile_avatar_link(48); ?> <strong><?php the_time('F jS, Y'); ?></strong> / <strong><?php the_author_link(); ?></strong> / <span class="comments"><?php comments_popup_link(__('0 comments','example'),__('1 comment','example'),__('% comments','example')); ?></span></span>
<?php the_excerpt(__('Continue reading ?','example')); ?>
</div><!-- /#post-<?php get_the_ID(); ?> -->
<?php endwhile; ?>
<div class="navigation">
<span class="newer"><?php previous_posts_link(__('? Newer','example')) ?></span> <span class="older"><?php next_posts_link(__('Older ?','example')) ?></span>
</div><!-- /.navigation -->
<?php else: ?>
<div id="post-404" class="noposts">
<p><?php _e('None found.','example'); ?></p>
</div><!-- /#post-404 -->
<?php endif; wp_reset_query(); ?>
</div><!-- /#content -->
<?php get_footer(); ?>