【问题标题】:Strange Message on WordpressWordPress 上的奇怪消息
【发布时间】:2016-04-09 13:39:49
【问题描述】:

<!--functions.php-->
<?php

function learningWordPress_resources() {

	wp_enqueue_style('style', get_stylesheet_uri());

}

add_action('wp_enqueue_scripts', 'learningWordPress_resources');

我在 wordpress 中的导航栏下方收到消息“class="home blog logged-in admin-bar no-customize-support">”,我正在从头开始编写代码。有谁知道如何删除这个?如果是这样,您的帮助将不胜感激:)

(由于依赖wordpress,附上的代码不会在这里运行。希望附上的图片足以说明情况)

/* 
CSS:
Theme Name: Yonsei Fencing
Author: Yonsei Student
Version: 1.0
*/
<!--index.php-->
<?php

get_header();

if (have_posts()) : 
	while (have_posts()) : the_post(); ?>

	<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
	<?php the_content(); ?>
	
	<?php endwhile;

	else: 
		echo '<p>No content found</p>';

	endif;

get_footer();

?>

<!--header.php-->
<!DOCTYPE html>
<html> <?php language_attributes(); ?>>
	<head>
		<meta charset="<?php bloginfo('charset'); ?>">
		<meta name="viewport" content="width=device-width">
		<title><?php bloginfo('name'); ?></title>
		<?php wp_head(); ?>
	</head>

<body> <?php body_class(); ?>>

	<!--site-header-->
	<header class="site-header">
		<h1><a href="<?php echo home_url(); ?>"><?php bloginfo('name'); ?></a></h1>
		<h5><?php bloginfo('description'); ?></h5>
	</header><!--/site-header-->


<!--footer.php-->
<footer class="site-footer">

	<p><?php bloginfo('name'); ?> - &copy; <?php echo date('Y');?></p>

</footer>

<?php wp_footer(); ?>
</body>
</html>

【问题讨论】:

  • 您是否在functions.php 文件中添加了任何自定义函数来自定义body 类?
  • 您好,我现在刚刚添加了一个,但似乎没有任何变化。

标签: php css wordpress


【解决方案1】:

问题在于函数 body_class() 属于 inside 你的 body 标记,但在你发布的代码中,它是 after body 标记.

如下更改您的代码,一切顺利:

FROM this,先关闭body标签:

<body> <?php body_class(); ?>>

到这里,它在body标签内包含body_class:

<body <?php body_class(); ?>>

【讨论】:

  • 谢谢先生! :)
猜你喜欢
  • 2012-11-21
  • 2011-07-15
  • 1970-01-01
  • 2016-01-31
  • 1970-01-01
  • 2010-12-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多