Suggestions
If you have ever installed and modified a theme to suit your likes, think of everything that could have been possible from within a simple admin menu, rather than having to edit template files.
Here are a few examples and ideas of additionnal features, which are easy to implement if you have some PHP knowledge.
I will detail the array part you have to edit in functions.php, as well as the PHP function you would add at the end of this file.
Set Layout Width
Giving the end user the possibility of setting his own layout width is piece of cake.
- Admin menu :
CODE:
-
array(
-
'width' => 'Overall Width ## Set layout width'
-
);
-
- Function :
CODE:
-
function mytheme_width() {
-
global $mytheme;
-
if ( $mytheme->option['width'] ) {
-
print '#wrap { width:';
-
print $mytheme->option['width'];
-
print " ;}\n";
-
}
-
}
-
- Usage :
Assuming you have a div named 'wrap' wrapping your layout, put the following in the <head> section of header.php :CODE:-
<style type="text/css">
-
<?php mytheme_width() ?>
-
</style>
-
Similarly and as easily, you could create options and functions to set anything regarding CSS and style : font color, sidebar floating left or right, location of a header background image ...
Optional Asides
Having to edit a theme's index.php to implement "Asides" is something that belongs to the past. Instead, you will just have the end user input the name of his Asides category in your admin menu :
- Admin menu :
CODE:
-
array(
-
'asides' => 'Asides ## Name of your "Asides" category (leave empty to use none)'
-
);
-
- Function :
CODE:
-
function mytheme_is_asides() {
-
global $mytheme;
-
$categories = array ();
-
foreach((get_the_category()) as $cat) {
-
$categories[] = $cat->cat_name;
-
}
-
if (in_array($mytheme->option['asides'],$categories)) {
-
return true;
-
} else {
-
return false;
-
}
-
}
-
- Usage :
You would now modify "The Loop" in your theme's index.php like this :CODE:-
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
-
-
<?php if ( mytheme_is_asides() and !is_single() ) { ?>
-
-
<!-- This post is an aside -->
-
<div class="asides">
-
<?php echo wptexturize($post->post_content); ?>
-
<a href="<?php the_permalink() ?>" rel="bookmark">«</a>
-
</div>
-
-
<?php } else { ?>
-
-
<!-- This post is not an asides: do things normally -->
-
<!-- Here goes your code to display posts -->
-
-
<?php } ?> <!-- end of aside or not -->
-
-
<?php endwhile; else: ?>
-
<p>Sorry, no post found.</p>
-
<?php endif; ?>
-
Setting default values
You can of course set default values so that when a user installs your theme, some values and options are already filled. To do so, add something like this at the end of your functions.php
-
// default options :
-
/* default values upon theme install */
-
if (!$mytheme->is_installed()) {
-
$set_defaults['some_option] = 'true';
-
$set_defaults['other_option'] = 'hello option';
-
$result = $mytheme->store_options($set_defaults);
-
}
Real Live Example
Why not install and try a real theme that uses Wordpress Theme Toolkit ? Go get Minimalissimplistic !
Related posts
Page: #1 #2 #3 #4 #5Shorter URL
Want to share or tweet this page? Please use this short URL: http://ozh.in/ko
Metastuff
189 Blablas
Pages: [19] 18 17 16 15 14 13 12 11 10 9 … 1 » Show All
Pages: [19] 18 17 16 15 14 13 12 11 10 9 … 1 » Show All
thought, on 21/Dec/09 at 8:23 pm # :
im a new web designer not good with php and i look for tutorials or some help of how to use wp theme toolkit.
i understand the basics and already have done some stuff with my new theme with it but i still need to do some more things but i cant
so any help plz ?
Thanks
wrote, on 27/Nov/09 at 6:10 pm # :
Sorry, I forgot to include to select 'Mac McDonald' as the contact in the form mentioned in my previous post.
said, on 27/Nov/09 at 6:07 pm # :
I just realized that I am using a modified version of themetoolkit.php that was included with the Simplicity theme by Lai Zit Seng. Lai fixed a bug with an extraneous dollar sign, and corrected some HTML ending tags in version 1.12.
If you will email me using the About->Contact Us form bluegrassmiataclub.com, I will send you this version.
commented, on 27/Nov/09 at 5:26 pm # :
This is an awesome tool for me! I have fixed a problem with checkboxes and now have it working under WP 2.8.6.
Here is the modified read_options()
pingback on 07/Sep/09 at 2:39 pm # :
[...] Theme ToolKit [...]
pingback on 07/Sep/09 at 2:39 pm # :
[...] Theme ToolKit [...]
pingback on 07/Sep/09 at 2:39 pm # :
[...] Theme ToolKit [...]
thought, on 23/Jul/09 at 7:32 am # :
Hey Ozh,
I known your are a busy person, but if you can bring the tool kit up to 2.8.1 compatibility will be more than great, you will make more people happy ;)
Theres a option to pay for this compatibility? Please let me know, write to my email.
Regards.
thought, on 23/Jun/09 at 3:55 pm # :
@Anil, the Toolkit does not use get_category but a customised one might ;)
You may be running into a WordPress problem here. 2.8 has a known issue with category functions and this has been fixed in 2.8.1, which is currently in beta testing.
See here for more info: http://wordpress.org/support/topic/280256?replies=26#post-1104991
I am running 2.8.1 Beta on some production sites now because of some of the issues in 2.8. You might like to consider doing the same (or waiting a bit for the final release). Try it on a test site first and see if the problem with your Toolkit goes away.