Wordpress - correct php link for images in media l

2019-07-10 00:26发布

I'm finalising a wp site I've built on my local server and removing all localhost links. I've added all the_permalink tags for pages but I'm struggling with the links for my img tags. I've tried <?php get_attached_media( 'ID' ) ?> and I've tried <? php wp_get_attachment_link() ?> and <? php wp_get_attachment_image() ?> but none seem to work.

What am I doing wrong? This is the code in my header file, for example, so its all standard code -

header.php

<div class="left-header">
            <img src="http://localhost:8888/wp-content/uploads/2017/07/Logo.png" alt="logo" id="logo" style="width:250px;height:30px;">
        </div>
    <div class="right-header">
         <div class="right-header-top">
            <div id="contact">
                <img src="http://localhost:8888/wp-content/uploads/2017/07/phone.png">
                <p>0113 220 5265</p>
                <img src="http://localhost:8888/wp-content/uploads/2017/07/email.png">
                <p>hello@media.co.uk</p>
            </div> 

Pretty much all the images I'm looking to change are in img tags.I'm sure this is a straightforward fix but I'm having a real brain freeze at the moment.

1条回答
做个烂人
2楼-- · 2019-07-10 00:43

Should be <?php echo home_url(); ?>, for example:

<img src="<?php echo home_url(); ?>/wp-content/uploads/2017/07/phone.png">
查看更多
登录 后发表回答