Submit Your Article Forum Rules

Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: need help on wordpress customization

  1. #11
    Senior Member Optic's Avatar
    Join Date
    Aug 2010
    Location
    Spokane, Wa
    Posts
    184
    It might be useful to checkout the `Hello Dolly` plugin that comes with WP. It prints a line from the song randomly.

    Here's how Matt did it:

    PHP Code:
    function hello_dolly_get_lyric() {
        
    /** These are the lyrics to Hello Dolly */
        
    $lyrics "Hello, Dolly
    Well, hello, Dolly
    It's so nice to have you back where you belong
    You're lookin' swell, Dolly
    I can tell, Dolly
    You're still glowin', you're still crowin'
    You're still goin' strong
    We feel the room swayin'
    While the band's playin'
    One of your old favourite songs from way back when
    So, take her wrap, fellas
    Find her an empty lap, fellas
    Dolly'll never go away again
    Hello, Dolly
    Well, hello, Dolly
    It's so nice to have you back where you belong
    You're lookin' swell, Dolly
    I can tell, Dolly
    You're still glowin', you're still crowin'
    You're still goin' strong
    We feel the room swayin'
    While the band's playin'
    One of your old favourite songs from way back when
    Golly, gee, fellas
    Find her a vacant knee, fellas
    Dolly'll never go away
    Dolly'll never go away
    Dolly'll never go away again"
    ;

        
    // Here we split it into lines
        
    $lyrics explode"\n"$lyrics );

        
    // And then randomly choose a line
        
    return wptexturize$lyricsmt_rand0count$lyrics ) - ) ] );

    Last edited by Optic; 05-04-2012 at 03:51 PM.
    I build custom WordPress themes and plugins with love, and occasionally post on my stupid blog about related topics. Contact me.

  2. #12
    Junior Member
    Join Date
    Nov 2010
    Posts
    4
    You can also use a javascript rotate.
    <script type="text/javascript">
    var adblock=new Array()
    adblock[0]='<img src="images/1.png" />'
    adblock[1]='<img src="images/2.png" />'
    adblock[2]='<img src="images/3.png" />'
    function randomorder(targetarray, spacing) {
    var randomorder=new Array()
    var the_one
    var z=2
    for (i=0;i<targetarray.length;i++)
    randomorder[i]=i

    while (z<targetarray.length) {
    the_one=Math.floor(Math.random()*targetarray.lengt h)
    if (targetarray[the_one]!="_selected!"){
    document.write(targetarray[the_one]+spacing)
    targetarray[the_one]="_selected!"
    z++
    }
    }
    }
    </script>

  3. #13
    Administrator weegillis's Avatar
    Join Date
    Oct 2003
    Posts
    5,785
    @avmood, I don't believe the OP is about client side rotation, but server side. There is only ever one image served to the client in what we're referring to above. Your script is pointless to this cause. Next time, please read the thread.

  4. #14
    Junior Member Ed Brown's Avatar
    Join Date
    May 2012
    Location
    Knoxville, TN
    Posts
    1
    i know it's been awhile since this topic was touched, but for future searchers of info I thought I would include some insight here. There is a plug-in called "Ad Codes" for wordpress which Supports AdSenseŽ, Javascript, XHTML and PHP code.The best part is that you can rotate endless numbers of ads(or photos, if you prefer, or whatever you wish, the plug in is extremely versatile) within the widget using the <!--rotate--> command.

    i'm not positive, but i suspect the widget could be hard coded into the functions.php file and placed anywhere you wished for the images/ads, etc to appear.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •