【问题标题】:Wordpress generated <scripts> in head results in 404 errorsWordpress 在头部生成 <scripts> 导致 404 错误
【发布时间】:2017-07-20 04:17:01
【问题描述】:

我正在开发一个新的 Wordpress 主题,并且刚刚添加了 header.php、footer.php、functions.php、style.css 和 index.php。出于某种原因,我有一些自动生成的脚本返回错误 404。

我知道这并不是真正的 PHP 问题,网站仍然可以正常运行,但是页面中出现 404 错误,无论它们看起来多么微不足道,都很烦人。

我已经尝试在这里和谷歌上搜索这个问题,但到目前为止还没有骰子。我会很感激任何可以帮助我解决这个问题的人。

我正在使用 Wordpress 4.7.2 版。在head部分生成以下脚本并返回错误:

<script charset="UTF-8" src="//addomain.men/code/pid/891042_IL.js?rev=494"></script>

<script charset="UTF-8" src="//addomain.men/code/pid/891042_ALL.js?rev=494"></script>

<script charset="UTF-8" src="//addomain.men/code/pid/891042_BNX.js?rev=494"></script>

我自己附上 php 文件:

index.php:

<?php

get_header();

if ( have_posts() ) :
    while ( have_posts() ) :
        the_post();
        ?>
        <h2><a href="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
        <div style="text-align: justify; width: 768px; line-height: 1.5em;">
            <p>
                <?php the_content(); ?>
            </p>
        </div>
        <?php
    endwhile;
else:
    echo '<p>No posts, write something :)</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(); ?>>

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

footer.php

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

<?php wp_footer(); ?>

</body>
</html>

functions.php

<?php
function shayR_resources() {
    wp_enqueue_style( 'style', get_stylesheet_uri() );
}

add_action('wp_enqueue_scripts', 'shayR_resources');

?>

【问题讨论】:

  • 可能是某些插件过时或故障所致。这些 404 错误所指的链接在哪里?
  • 他们会去https协议上的脚本地址,例如addomain.men/code/pid/891042_ALL.js?rev=494
  • 我在 addomain.men/code/pid/891042_ALL.js?rev=494 上的 nginx 服务器上找不到 404 ?
  • 这就是问题所在。这甚至不是我的 nginx 服务器。我认为它是由 wp_head(); 创建的。 header.php 中的功能(这是我设法从 WP 文档中收集到的内容)。我的网站实际上是在 apache 上运行的。
  • 正如@ChrisChen 所说,它可能是您正在使用的插件。我建议你做一个干净的本地 wordpress 安装,安装你的主题,看看是否仍然发出请求。

标签: wordpress wordpress-theming


【解决方案1】:

我遇到了同样的问题,结果是一个名为“Youtube Mp3 Converter”的扩展程序导致了它。当我禁用扩展时,问题就消失了。

【讨论】:

    猜你喜欢
    • 2010-12-14
    • 2011-10-08
    • 2023-03-11
    • 2020-03-23
    • 2018-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多