Solved

Wordpress Custom Theme Concepts

Posted on 2014-01-16
5
444 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
  • 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 400 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 100 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now