Php WordPress中的视差

Php WordPress中的视差,php,wordpress,localhost,parallax,Php,Wordpress,Localhost,Parallax,我的page-parralax.php文件中有以下视差代码: get_header(); ?> <?php $args = array( 'post_type' => 'parallax', 'order' => 'ASC', 'orderby' => 'menu_order' ); $parallax = new WP_Query($args); while($par

我的page-parralax.php文件中有以下视差代码:

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_header();?>
你得往上走:

background:url(“../…”)

我已经删除了尾随斜杠,因为您的URL以它开头。您也可以考虑设置<代码> <代码> URL,并从开始时使用相对URL。

您可以<代码> VARXDUMP($DURURL)< /代码>并检查它吗?当然可以。它返回:string(57)“/wp content/uploads/2015/10/16GyTew-1024x6781-700x463.jpg”那么你在问题中提到的url是如何创建的?如果我正确理解了你的问题,我会在css中这样调用图像:style=“background:url('../”)它是macbook\u overview\u og-700x700.jpg
16GyTew-1024x6781-700x463.jpg
的$breakUrl?这就解决了它。谢谢!
background: url('../..<?= $breakUrl; ?>')