我已经在我的页面parralax.php文件下面视差代码:视差WordPress的
get_header(); ?>
<?php
$args = array(
'post_type' => 'parallax',
'order' => 'ASC',
'orderby' => 'menu_order'
);
$parallax = new WP_Query($args);
while($parallax->have_posts()) : $parallax->the_post();
$parallaxImage = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large');
$breakUrl = str_replace('http://localhost/themes', '', $parallaxImage[0]); ?>
<div class="wrapper">
<div class="container">
<div id="clearfix">
<section class="parallax" id="section_<?php echo the_ID(); ?>" style="background: url('../<?php echo $breakUrl; ?>') fixed;"></section>
<section id="section_<?php echo the_ID();?>" class="parallax" style="background: url('../<?php echo $breakUrl; ?>') fixed;"></section>
<div class="parralax-container">
<h2><?php the_title(); ?></h2>
<div class="page-content">
<?php the_content();?>
</div>
</div>
</div>
</div>
</div>
<?php
endwhile;
wp_reset_postdata();
get_footer();
?>
但是,当我尝试看看它,它返回以下错误:
GET http://localhost/themes/index.php/wp-content/uploads/2015/10/macbook_overview_og-700x700.jpg 404(未找到)为每个图像。
如果我在控制台后来更改为:
http://localhost/themes/wp-content/uploads/2015/10/macbook_overview_og-700x700.jpg它显示正确。
这是因为我使用localhost它会产生这个错误吗?
你可以'var_dump($ breakUrl)'检查它吗? – raina77ow
当然。它返回:字符串(57)“/wp-content/uploads/2015/10/16GyTew-1024x6781-700x463.jpg” –
那么你在问题中提到的网址怎么样? – raina77ow