Home › Forums › General Issues › Simple URL Field › Reply To: Simple URL Field
I am a PHP novice and have the following problem and I really hope someone can help as I cannot find the answer in any of the support forums: I want a non-tech WP admin to be able to change the image on a home page of a WordPress 4.1 site.
I have successfully created an Image Object field and Image metabox that works just fine on a test page, but every time I try to replace the existing $home_banner image variable in the live home page template, it doesn’t work. I have also tried an Image URL field but it just renders in HTML as
I have set up an Image Object field called ‘image-main’ and I want to use it to replace the existing variable $home_banner variable in the following code. Can anyone tell me how to edit the existing page template do this. Thanks. Existing live code snippet is below:
$home_banner = get_stylesheet_directory_uri() . ‘/library/images/’;
if (is_mobile()) {
$home_banner .= ‘home-banner-medium.jpg’;
}
else { $home_banner .= ‘home-banner.jpg’;
}
<script>window.home_banner = “<?php echo $home_banner; ?>”;</script>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class=”banner”>
<h1>Bringing nature to you <span>wherever you are</span></h1>
</div>
The particular home page is here: http://inhouse-test.indoorgardendesign.com/
Thanks in anticipation.
SJL
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.