如何在wordpress主题中注册html页面的Css

Posted

技术标签:

【中文标题】如何在wordpress主题中注册html页面的Css【英文标题】:How to register Css of html page in wordpress theme 【发布时间】:2016-12-15 03:08:17 【问题描述】:

我是 wordpress 开发的新手。我试图将响应式 html 页面转换为 wordpress 主题,但 html 页面的 CSS 在 wordpress 主题中无法正常工作。请看下面的图片:

HTML 页眉

wordpress 主题标题

我无法弄清楚为什么 wordpress 主题标题与 html 页面标题不同,而 Style.css 相同。 请向我建议如何解决这个问题。

【问题讨论】:

在你的 header.php 中有这样的东西吗? 是的,我已经通过上述方法包含了style.css 【参考方案1】:

这里是调用WordPress目录图片,样式或帖子等的所有过程,请检查它。

 default CSS call 
<link href="<?php bloginfo('stylesheet_url'); ?>" rel="stylesheet" type="text/css" media="screen" />

 <a href="php?page_id=318"><h6 class="add-to-cart"></h6></a>-------page call

  <?php get_header(); ?>---------------------------------------header show

  <?php get_sidebar(); ?>--------------------------------------to call slider.php

  <?php dynamic_sidebar( 'sidebar name  include ' ); ?>-----to show slider wigdts

  <?php dynamic_sidebar('New 1'); ?>---------------------------sidebar 

  <?php get_footer(); ?>---------------------------------------footer show

  <?php get_template_directory(); ?> --------------------------dirctory path

  <?php echo get_template_directory_uri(); ?>------------------script path

  <?php the_title(''); ?>--------------------------------------title show

  <?php the_excerpt(''); ?>------------------------------------content show 

  <p><?php echo substr(get_the_excerpt(), 0,170); ?></p>------content LIMIT 

  <?php get_search_form(); ?>-----search 

  <?php the_permalink(''); ?>----------------------------------post ka link(like click on title of post and it show inside the post)

  <?php bloginfo('template_url');?>/images---------------------image path 



  <link href="<?php bloginfo('template_url'); ?>/css/global-style.css" type="text/css" rel="stylesheet">-- css path in header file

  <?php echo the_post_thumbnail(''); ?>------------------------image show

还有很多,但是列表太长了,它会帮助你把静态的html变成动态的

【讨论】:

我已经添加了 标题,但我仍然面临这个问题 进入你的header.php,一一更改样式表的调用方法 代替这段代码 1 2 3 先生,我已经在 header.php 上添加了这个以包含 style.css 但同样的问题出现了 再次阅读评论,你能告诉我你的网站链接吗?您在 single.php 或 page.php 中编写的代码应该是 index.php 的副本 它在 localhost 中,所以我无法向您展示。先生,您能解释一下您的评论吗?我无法理解这一点。请先生解释一下【参考方案2】:

在您的 function.php 上找到 wp_register_style 函数

你可以在那里添加你的自定义样式表文件

wp_register_style('THEMENAME', get_template_directory_uri() . '/style.css', array(), '1.0', 'all');
wp_enqueue_style('THEMENAME'); 

【讨论】:

wp_register_style 不在我的 fucntion.php 文件中。您能否提供一下我该如何做到这一点,因为使用上述方法我遇到了胎儿错误。请帮忙 so you cn 创建它 -- function NAME() wp_register_style('THEMENAME', get_template_directory_uri() . '/style.css', array(), '1.0', 'all'); wp_enqueue_style('主题名'); 没有。出现同样的问题。你能给我提供其他选择吗? 您的自定义样式表文件的名称是什么?它在某个目录中吗?还是在主主题文件夹中? style.css 是名称,它与 header.php 和 footer.php 位于同一文件(wordpress 文件夹)中

以上是关于如何在wordpress主题中注册html页面的Css的主要内容,如果未能解决你的问题,请参考以下文章

转载:如何在wordpress主题中添加设置页面

访问下划线主题中的非wordpress php文件

wordpress怎么添加留言板

关于wordpress主题侧边栏菜单

如何调整 Wordpress 二十一十一主题,使页面宽度为 100% 并居中?

如何在我的 WordPress 主题上获得粘性页脚?