Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Jan 2006
    Posts
    88
    Thanks
    4
    Thanked 1 Time in 1 Post

    Wordpress: Display the page names & descriptions on homepage, not posts? (example in)

    I want to achieve something like this, but showing the pages instead of posts. http://wordpress.org/extend/themes/threattocreativity

    And also have an array of pre defined colours, as at the moment it just seems to do random hex codes

    PHP Code:
    style="cursor:pointer;background:#<?php echo rand(09); ?><?php echo rand(09); ?><?php echo rand(09); ?><?php echo rand(09); ?><?php echo rand(09); ?><?php echo rand(09); ?>;"
    Is this possible?

  • #2
    Regular Coder poyzn's Avatar
    Join Date
    Nov 2010
    Posts
    266
    Thanks
    2
    Thanked 61 Times in 61 Posts
    use get_pages to get pages you want on a home page and then output them in a loop

  • Users who have thanked poyzn for this post:

    reyna12 (11-13-2012)

  • #3
    New Coder
    Join Date
    Jan 2006
    Posts
    88
    Thanks
    4
    Thanked 1 Time in 1 Post
    Brilliant, thanks. Will give that a go.

    How would i go about setting the background to instead of using a random number like in the code in original post, use a list of pre-defined colours?

  • #4
    Regular Coder poyzn's Avatar
    Join Date
    Nov 2010
    Posts
    266
    Thanks
    2
    Thanked 61 Times in 61 Posts
    Quote Originally Posted by reyna12 View Post
    Brilliant, thanks. Will give that a go.

    How would i go about setting the background to instead of using a random number like in the code in original post, use a list of pre-defined colours?
    What color of background do you want?

  • #5
    New Coder
    Join Date
    Jan 2006
    Posts
    88
    Thanks
    4
    Thanked 1 Time in 1 Post
    Haven't picked them out yet but various shades of orange.

  • #6
    Regular Coder poyzn's Avatar
    Join Date
    Nov 2010
    Posts
    266
    Thanks
    2
    Thanked 61 Times in 61 Posts
    define your colors in css file and then use as classes:
    Code:
    /* style.css */
    .orange1 { background-color: #f00; }
    .orange2 { background-color: #0f0; }
    .orange3 { background-color: #00f; }
    in layout:
    Code:
    <div class="orange1">...</div>

  • #7
    New Coder
    Join Date
    Jan 2006
    Posts
    88
    Thanks
    4
    Thanked 1 Time in 1 Post
    The pages are generated by an array though i think? so the
    Code:
    <div class="orange1">
    would need to be $random?

  • #8
    Regular Coder poyzn's Avatar
    Join Date
    Nov 2010
    Posts
    266
    Thanks
    2
    Thanked 61 Times in 61 Posts
    Quote Originally Posted by reyna12 View Post
    The pages are generated by an array though i think? so the
    Code:
    <div class="orange1">
    would need to be $random?
    PHP Code:
    <div class="orange<?= rand(1,3?>">
    ?

  • #9
    New Coder
    Join Date
    Jan 2006
    Posts
    88
    Thanks
    4
    Thanked 1 Time in 1 Post
    Quote Originally Posted by poyzn View Post
    PHP Code:
    <div class="orange<?= rand(1,3?>">
    ?
    Thanks, will try that.


  •  

    Posting Permissions

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