IMG SRC纠正,但仍然无法在工作的index.php(Img Src correct, but

2019-10-29 14:26发布

我相信我已经在正确的HTML源图像的(超级基本)wordpress主题,我发展; 但是它仍然没有显示。

这种对话: IMG SRC本地计算机上显示的进程迄今(其中我已经放心的HTML是正确的。)

的index.php的身体:

<?php
    $main_menu_column_top = array(
        'theme_location' => 'main-nav-column-top',
        'container' => 'nav',
        'container_class' => 'alignleft widecol',
        'container_id' => 'column-main-nav',
        'depth' => 1
    );
?>

<div class="leftcolumn">
    <div class="logo">
        <a href="http://www.petermaurin.com">
        <img src="images/pmsplogo.jpg" alt="Peter Maurin Screenprinters"/></a>
    </div><!--logo-->

    <div>
        <ul>
            <h1><?php wp_nav_menu ( $main_menu_column_top ); ?></h1>
        </ul>
    </div>
</div>

<div class="maincontent">

    <?php 
        if (have_posts()) :
            while (have_posts()) :
                the_post();
                the_title();
                the_content();
            endwhile;
        endif;
    ?>

    </div><!-- maincontent -->

的functions.php:

<?php
register_nav_menus(
        array(
        'main-nav-column-top' => 'Main Nav, Top of Header',
        'sub-nav-column-bottom' => 'Sub Nav, Bottom of Header',
        'footer-nav' => 'Footer Menu'
    )
);

CSS:

* {
margin: 0;
padding: 0;
}

p {
font-family: Times New Roman;
}

body {
    font-size: 100%;
    font-family: sans-serif;
    background: url(images/tshirttexture.jpg) left repeat-y #0099ff;
}

.leftcolumn{
    width:365px;    
    float:left;
}

.maincontent{
    background-color:green;
    margin-left: 375px;
    max-width: 600px;
}

......如果任何人都可以去看看,让我知道为什么我的形象(“pmsplogo.jpg”上线的index.php 26)不显示,我会非常感激!

Answer 1:

在img元素的src属性应该是这样的

<?php bloginfo( 'template_url' );?>/images/pmsplogo.jpg

所以基本上完​​整的图像URL将是:

<img src="<?php bloginfo( 'template_url' );?>/images/pmsplogo.jpg" alt="Peter Maurin Screenprinters"/>


Answer 2:

<img src="<?php echo 'dirname(__FILE__)'.'/images/pmsplogo.jpg'?>" />

不要用“写http://www.yoursitename.com/在PHP”,他们无法找到它的源。



文章来源: Img Src correct, but still not working in index.php