Child theme background Problem
-
Hello. I’m using a child theme who has 5 boxes with a supposed graphic background. To load that photos first the child makes an array:
<?php $settings = array( // IMAGES 'sampledata' => array( 1 => array("name" => "", "img" => home_url()."/wp-content/themes/childtheme/img/cat1.jpg", "icon" => ""), 2 => array("name" => "", "img" => home_url()."/wp-content/themes/childtheme/img/cat2.jpg", "icon" => ""), 3 => array("name" => "", "img" => home_url()."/wp-content/themes/childtheme/img/cat3.jpg", "icon" => ""), 4 => array("name" => "", "img" => home_url()."/wp-content/themes/childtheme/img/cat4.jpg", "icon" => ""), 5 => array("name" => "", "img" => home_url()."/wp-content/themes/childtheme/img/cat5.jpg", "icon" => ""), 6 => array("name" => "", "img" => home_url()."/wp-content/themes/childtheme/img/cat5.jpg", "icon" => ""), ), ); ?>
Then that images are processed similar to this:
<div class="col-12 col-sm-6 col-md-4 cat-item"> <div style="background-image: url('<?php echo $savadata[1]['image']; ?>');" class="cat-image"> <a href="<?php echo $savadata[1]['link']; ?>" class="cover-wrapper"><?php echo $savadata[1]['name']; ?></a> </div> </div> <div class="col-12 col-sm-6 col-md-4 cat-item"> <div style="background-image: url('<?php echo $savadata[2]['image']; ?>');" class="cat-image"> <a href="<?php echo $savadata[2]['link']; ?>" class="cover-wrapper"><?php echo $savadata[2]['name']; ?></a> </div> </div> <div class="col-12 col-sm-6 col-md-4 cat-item"> <div style="background-image: url('<?php echo $savadata[3]['image']; ?>');" class="cat-image"> <a href="<?php echo $savadata[3]['link']; ?>" class="cover-wrapper"><?php echo $savadata[3]['name']; ?></a> </div> </div> <div class="col-12 col-sm-6 col-md-4 cat-item"> <div style="background-image: url('<?php echo $savadata[4]['image']; ?>');" class="cat-image"> <a href="<?php echo $savadata[4]['link']; ?>" class="cover-wrapper"><?php echo $savadata[4]['name']; ?></a> </div> </div> <div class="col-12 col-sm-6 col-md-4 cat-item"> <div style="background-image: url('<?php echo $savadata[5]['image']; ?>');" class="cat-image"> <a href="<?php echo $savadata[5]['link']; ?>" class="cover-wrapper"><?php echo $savadata[5]['name']; ?></a> </div> </div> <div class="col-12 col-sm-6 col-md-4 cat-item"> <div style="background-image: url('<?php echo $savadata[6]['image']; ?>');" class="cat-image"> <a href="<?php echo $savadata[6]['link']; ?>" class="cover-wrapper"><?php echo $savadata[6]['name']; ?></a> </div> </div>
But the image never arrives there. Well it arrives but not seen. For example. I put this in any place in that code without affected just to monitor and what value returns:
<?php echo $savadata[1]['image']; ?>
And on the screen I see “Array”, then I know now the background url is entered as the word “Array” and is not valid. Now I enter this command to monitor if it is really right, the same as the previous one, just to monitor:
<?php print_r(array_values($savadata[1]['image'])); ?>
And here I see the perfect value:
Array ( [0] => [1] => https://xxx.xxx.xxx.xxx/tests/wp-content/themes/childtheme/img/cat1.jpg [1] => )
That is the value and is the correct link, well here I entered xxx to hide our ip for security, but is ok the result given for the command. But how can I enter in the “DIV” command the background url from there? In other words extract real the Srray value as I did with the print_r command where there it shows, but applicable to the “DIV” command.
As can be seen the default command echo “$savadata[1][‘image’]“ and monitoring it gives “Array” word, and I suppose that is the problem the “DIV” is calling a bad link maybe.
How can be solved?
Thank you
- The topic ‘Child theme background Problem’ is closed to new replies.