treehouse : what would you like to learn today?
Web Design Web Development iOS Development

How to add block of editable text to wordpress homepage?

  • Hi guys

    Bit of a wordpress amateur here.

    I am creating a theme. On the home page there will be 2 sections...

    Latest post excerpt (I know how to do this!)

    An 'About us' section - paragraph of text which I would like the client to be able to edit in the admin section, so not hard-coded. How can I create the code for this?

    I am thinking of creating a page in the admin, then use PHP includes on the home page to display that page, but I don't think this is the best way.

    Any help would be great.

    Thanks

  • Either a custom post type 'about' and the client can input their text via the text editor or by using custom fields which you can add to certain sections (or all) of the backend.

  • To do this you should just style the page.php file with your wrapper or however you are setting you website up. That's what WordPre uses to set up individual pages such as an about page, contact page. Where as the blog uses the index.php file, and the single blog post uses the single.php file.

    EDIT: sorry I misread the question. +1 on @chrisburton's comment.

  • @chrisburton, ignore what I said above. I originally misread the original question. Custom fields are a good idea, I should know haha!

  • Ha. No problem. I would probably setup a custom page rather than a custom post type now that I think about it. And in the backend I would have a custom field for the description. However, it really depends on the design.

  • Hey thanks for the quick responses.

    So Chrisburton, just to confirm...

    1. I currently have a page set up called 'Home' in the admin.
    2. On this page add a custom field for the description.
    3. In my front-page.php file, add a snippet such as ...

      <?php echo get_post_meta($post->ID, 'key', true) 
      

    ...where I would like the description to appear.

    Does that sound about right?

  • @croydon86 Yes, exactly. I use the 'More Fields' plugin for my custom fields which is super simple but some like 'Advanced Custom Fields'.

    Here is a screenshot of my backend. http://cloud.chrisburton.me/LDgp

  • @chrisburton thanks a lot for your help. I really appreciate it.

    This seems to have done the trick!

  • Glad to hear. Let us know if you have any further questions.