Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Wordpress Custom Theme Concepts

Posted on 2014-01-16
5
Medium Priority
?
464 Views
Last Modified: 2014-01-18
I've decided to start doing my sites in Wordpress because more and more clients are asking for a CMS to edit their site.  It seems like a good fit - and it's easy to install and use, so - why not.

As I'm trying to take the next step and create a custom theme, including a home.php page that mimics my site, I'm struggling to come up with the best way to do it.

I include get_header(), get_sidebar(), and get_footer() in the home.php file, including all my text and images from the original design.

This particular page has a few paragraphs on it - and Ideally it would be great if the users could change this without needing to access home.php.   Is this possible?  The page doesn't show up in "pages" in Wordpress' back end - (and I'm sure missing whatever code would be needed anyway (on home.php) to take a value from the database.)

Also, the right column (side_bar) is kind of similar throughout the entire site with 2 or 3 sections: a block quote, an area for quick facts, and all pages except the home page also have a quick contact form.

Since I want the block quotes and quick facts to be different on each page (user input) I was wondering if custom fields were the best way to do this, or if there was a better way.

Hope this isn't too confusing of a question.  Thanks for the help!
0
Comment
Question by:slightlyoff
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 38

Expert Comment

by:Tom Beck
ID: 39785662
In WordPress, it's common to generate all content via posts. The key mechanism is "The Loop" as described here:

http://codex.wordpress.org/The_Loop

To restrict which posts appear on which page of the site you can compose your content in posts and then divide your posts into categories. Then in the php file for the page you want to fill with content, restrict the Loop to only those posts from a certain category like this:

<?php query_posts('cat=2'); ?>

In addition to your custom home.php page you may want to create other custom pages to display different posts as content. Creating custom pages is easy, just clone the home.php page, rename it, and place the required template info at the top. Doing this causes the template to appear in the drop down list of templates when creating new pages in the Dashboard. An example of what to place at the top of a template page:

<?php
/*
 * Template Name: About Page Template
 * Description: About page template.
 */
?>

The words "About Page Template" will appear in the drop down for you to select when you create an About page for example.

Keep all templates including the custom home.php in the child theme folder.
0
 
LVL 1

Author Comment

by:slightlyoff
ID: 39785713
Perfect!  

Just to clarify - I'd create a page called homepage content, put it in a category and in my home.php file I'd limit the query_posts inside The Loop to the category that has the homepage content in it.  Right?

Thanks for the quick reply!
0
 
LVL 38

Accepted Solution

by:
Tom Beck earned 1600 total points
ID: 39785995
Set up your WP file structure like this if you have not already:

<root>/wp-content/themes/<parent theme>
    --> original home.php
    --> original functions.php
    --> original styles.css
    --> etc, etc,

<root>/wp-content/themes/<child theme>
    --> cloned, customized home.php
    --> cloned, customized functions.php (if needed)
    --> cloned, customized styles.css (if you want to tweak the original theme)
    --> <page template 1 name>.php (these can be clones of home.php to start with)
    --> <page template 2 name>.php
    --> <page template 2 name>.php
    --> etc, etc.

Be sure to name each template in the comment area at the top of the php file.

You can use the cloned home.php as your customized home page or rename it homepage.php or whatever. You can designate any page as the home page.

It's important to set up the file structure this way because you will inevitably have to reinstall WordPress somewhere down the line. By keeping all of the customized files in one place, you can back that up and reinstall WP without worry. Never alter original WP files.

Now, from the WP Dashboard, create categories for posts. A category corresponding to each page name.

Create new post(s) for the content you want to appear on each page and be sure to check the appropriate post category that corresponds to the page name.

On your <page template 2 name>.php files add the <?php query_posts('cat=2'); ?> to the code where appropriate to add only the posts associated with that page.
0
 
LVL 70

Assisted Solution

by:Jason C. Levine
Jason C. Levine earned 400 total points
ID: 39787364
slightlyoff,

Please read this WordPress Codex entry on Template Hierarchy

http://codex.wordpress.org/Template_Hierarchy

Basically, you want to create custom templates and then match them up to something (read the article see the definition of "something") like the post ID or slug and then use custom fields to control any variable content.
0
 
LVL 1

Author Closing Comment

by:slightlyoff
ID: 39791279
Thanks for your help - I think I'm getting the hang of it.  I'm posting another question about best practices - and would love your feed back.

Thanks again!
0

Featured Post

Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you use a default hosting installation of wordpress with the intention of it being your actual site?  Maybe you’ve installed it as a Blog to your current site and recently converted it to be the main site and do away with the old .htm pages.  An…
What's this? As a volunteer Page Editor for Experts-Exchange.com, I have noticed that many authors also have blogs, and pull articles from their blogs to post at Experts-Exchange. I appreciate each author sharing their blog content with our site …
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Open Page or Post…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question