spspsp Posted January 31 Posted January 31 I'm trying to get a button on my home page that links to a random post on my site, but have no idea how to do it. I've tried to look at a couple other answers... can anyone out there help simplify it for me?
spspsp Posted January 31 Author Posted January 31 I've tried using this help, but the header code does not seem to affect the button block.
tuanphan Posted February 4 Posted February 4 Which exact code did you use? We can tweak it easier Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
spspsp Posted February 6 Author Posted February 6 <script> $( ( ) => { /* begin change button url to random page Version : 0.1d0 SS Version : 7.1 Dependancies : jQuery By : Thomas Creedon < http://www.tomsWeb.consulting/ > */ // enter button block id without the # const buttonBlockId = '#block-yui_3_17_2_1_1706584972305_1843 a'; const urlPrefix = '/read-this-trashh'; // do not change anything below, there be the borg here let r = Math.floor ( Math.random ( ) * 100 ); r = String ( r ).padStart ( 3, '0' ); const url = urlPrefix + r; $( '#' + buttonBlockId + ' a' ).attr ( 'href', url ); } ); /* end change button url to random page */ </script>
spspsp Posted February 6 Author Posted February 6 when it worked that code seemed to only drop me at the category page, not a random page within the category (if it was the code that was doing that)
tuanphan Posted February 8 Posted February 8 enter list url to this line const urlPrefix = '/read-this-trashh'; it should be const urlPrefix = '/read-this-trashh, /shop/product2, /shop/product3'; (just an example) Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment