简体   繁体   English

为什么 index.php 会出现在我的图片链接路径中?

[英]Why is index.php showing up in my image link paths?

I'm building a theme using a local server(xampp).我正在使用本地服务器(xampp)构建主题。 I have created a setting through the customizer where someone can select from a number of backgrounds I created using a dropdown list.我通过定制器创建了一个设置,有人可以从我使用下拉列表创建的许多背景中进行选择。 Everything was working fine in live-preview and on the static home page.在实时预览和静态主页上一切正常。 As soon as I created a new page I get a 404 error and this path for the image: http://localhost:777/wordpress-5.8/wordpress**/index.php/front-page/**wp-content/themes/sophia-valeria/backgrounds/bgg33.jpg一旦我创建了一个新页面,我就会收到 404 错误和图像的路径:http://localhost:777/wordpress-5.8/wordpress**/index.php/front-page/**wp-content/主题/sophia-valeria/backgrounds/bgg33.jpg

Obviously, that link is not going to work.显然,该链接将不起作用。 I'm not sure why this is happening.我不确定为什么会这样。

I do note that every time I create a page it has index.php in the url, but the home page does not.我确实注意到,每次我创建一个页面时,它的 url 中都有 index.php,但主页没有。

My css looks like this:我的 css 看起来像这样:

         <style>
    body{ background-repeat:no-repeat;
    background-size:100% 100%;
    background-image: url(<?php echo(get_theme_mod('backgrounds_setting', get_stylesheet_directory() . '/backgrounds/bgg33.jpg'));?>);}
     </style> <?php }
    add_action( 'wp_head', 'understanding_bg'); ```

I don't know whether this is a weird apache thing or what. Any ideas on what I have to do to make the images not incorporate page titles and index.php. I am definitely missing something here. 

Try this way试试这个方法

function understanding_bg(){                  ?>
         <style>
    body{ background-repeat:no-repeat;
    background-size:100% 100%;
    background-image: url("<?php echo get_stylesheet_directory() . '/backgrounds/bgg33.jpg';?>");}
     </style> <?php }
    add_action( 'wp_head', 'understanding_bg'); 

Or directly place the whole path for the background image.或者直接放置背景图片的整个路径。

background-image: url("/wp-content/themes/yourThemeName/backgrounds/bgg33.jpg");

If the above one is not working, try this one.如果上述方法不起作用,请尝试使用此方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM