Solved

Wordpress Custom Theme Concepts

Posted on 2014-01-16
5
440 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Now that you've installed WordPress 2.9 (http://www.experts-exchange.com/articles/Web_Development/Blogs/WordPress/WordPress-2-9-What-to-Expect-When-Upgrading-to-WordPress-2-9.html?) on your site, you need to install some plugins to get the most out …
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…
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…

746 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

14 Experts available now in Live!

Get 1:1 Help Now