Grow your CSS skills. Land your dream job.

How to add block of editable text to wordpress homepage?

  • # December 3, 2012 at 6:20 pm

    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

    # December 3, 2012 at 6:27 pm

    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.

    # December 3, 2012 at 6:28 pm

    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.

    # December 3, 2012 at 6:30 pm

    @Watson90 Huh?

    # December 3, 2012 at 6:33 pm

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

    # December 3, 2012 at 6:36 pm

    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.

    # December 3, 2012 at 7:16 pm

    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?

    # December 3, 2012 at 7:22 pm

    @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

    # December 4, 2012 at 3:34 pm

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

    This seems to have done the trick!

    # December 4, 2012 at 3:46 pm

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

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".