- This topic has 11 replies, 4 voices, and was last updated 5 years, 8 months ago by Tom.
-
AuthorPosts
-
January 18, 2018 at 9:47 am #474282JJ Smith
So I want to do randomized header images that work the same way it does if you add your logo to the customize area in GP.
Any ideas on how to do this?
January 18, 2018 at 1:35 pm #474418LeoStaffCustomer SupportHi there,
Not sure what you mean by “the same way way it does if you add your logo to the customize area in GP”?
We don’t have randomize logo features.
Can you provide an example?
January 18, 2018 at 4:37 pm #474533JJ SmithThat’s what I’m looking for is randomize logos.
Any idea of any plugin that does that?
Thanks,
JJJanuary 18, 2018 at 9:21 pm #474618TomLead DeveloperLead DeveloperSo the image would change on refresh, or without refresh (slider)?
January 19, 2018 at 1:46 am #474705JJ SmithChange on refresh.
Thanks,
JJJanuary 19, 2018 at 10:23 am #475107TomLead DeveloperLead DeveloperYou could do something like this in the Before Header Content hook:
<?php $headers = array( 'URL to logo 1', 'URL to logo 2', 'URL to logo 3', 'URL to logo 4', ); $random = $headers[ rand( 0, count( $headers ) -1 ) ]; echo '<img src="' . $random . '" alt="" />'; ?>
July 12, 2018 at 5:16 am #621867WilliamThanks for pointing out how to insert the code using the Hooks module.
It works perfectly! https://kickngliders.org/wp/
July 12, 2018 at 9:14 am #622157TomLead DeveloperLead DeveloperAwesome 🙂
July 24, 2018 at 2:12 pm #631887WilliamThe random header image has been working perfectly but now it only works about half the time. Sometimes I get one of the randomized images. Other times I get no header at all. The code I inserted in the Before Header hook follows. I disabled the hook and put one of the header images in via site identity and it works normally. Re-enabled the hook and it’s random again.
I had installed a couple of Plugins since I put the hook in but I’ve disabled them with no change. I did add an additional 150 pages since I the images were reliable.
Site URL is: https://kickngliders.org/wp/
Thanks for any help you can offer!
Bill Stine
<?php
$headers = array(
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_9985.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMGP3557.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMGP3548.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_9677.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_9681.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_9675.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_9590.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_9667.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_9589.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_1302.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_3243.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_1272.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_1275.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_1267.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_1269.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_1266.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_1247.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_1251.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_0267.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_0241.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_0244.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_0226.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_0227.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_0218.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_0066.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_0070.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/IMG_0056.jpg’,
‘https://kickngliders.org/wp/wp-content/uploads/2018/07/DSCN3626.jpg’,
);$random = $headers[ rand( 0, count( $headers ) -1 ) ];
echo ‘‘;
?>July 24, 2018 at 7:39 pm #632060TomLead DeveloperLead DeveloperThat looks ok to me. Are you sure all of those URLs are working correctly?
July 25, 2018 at 5:53 am #632348WilliamColor me embarrassed! I recently installed and used the plugin, Media Library Folders for WordPress, to organize my media and moved all those images into their own folder. The plugin does update the URL in pages that use the file. I didn’t account for the fact that the plugin apparently does not update the hooks code. What baffled me was that it worked ok about half the time. I suppose it might have something to do with caching? Anyway, my bad.
It’s working perfectly now. Thanks, again, for your rapid and thoughtful response!
Bill
July 25, 2018 at 10:27 am #632612TomLead DeveloperLead DeveloperGlad you got it working 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.