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 #5Metastuff
154 Blablas
Pages: « 1 2 3 4 5 6 7 [8] Show All
Pages: « 1 2 3 4 5 6 7 [8] Show All
commented, on 29/Jun/08 at 11:08 am # :
Just wanted to say thank you for that wonderful Kit.
pingback on 01/Jul/08 at 11:07 am # :
[...] Theme ToolKit [...]
pingback on 01/Jul/08 at 1:28 pm # :
[...] Wordpress Theme Toolkit « planetOzh [...]
pingback on 03/Jul/08 at 4:54 am # :
[...] pensado liberar el theme WP-Resurrection pero como queria añadirle algunas opciones intente usar Wordpress Theme Toolkit pero tuve algunos errores con el y la verdad no soy tan experto en PHP como para arreglarlo. [...]
pingback on 04/Jul/08 at 5:41 am # :
[...] their latest sketch shoved down the throat of their visitors. With some help from planetOzh’s Theme Toolkit, I put together a YouTube embed box that can be easily changed from the admin [...]
pingback on 09/Jul/08 at 12:32 pm # :
[...] Theme Toolkit Puede ser el mas conocido de todos, Lo use en versiones anteriors de wordpress, pero ahora me da error. Puede ser por mi poco conocimiento de PHP, pero es muy bueno! [...]
commented, on 14/Jul/08 at 9:12 pm # :
i cant do it.
pingback on 19/Jul/08 at 8:23 pm # :
[...] Theme ToolKit [...]
wrote, on 04/Aug/08 at 4:34 am # :
That's great, I have been looking for the solution, found here finally, thanks.
pingback on 12/Aug/08 at 11:27 pm # :
[...] also seems quite interesting, and helped me in my original attempt to display this info using the Planet Ozh WordPress Theme Toolkit functions file (I may talk about the Theme Toolkit in a following article or tutorial in this [...]
pingback on 23/Aug/08 at 11:17 pm # :
[...] WordPress Theme Toolkit [...]
said, on 25/Aug/08 at 3:45 am # :
Thanks for the solution !!
pingback on 28/Aug/08 at 4:51 pm # :
[...] WordPress Theme Toolkit is a tool that allows theme authors add an admin menu as easily as editing 3 lines, and it powers [...]
said, on 01/Sep/08 at 3:23 am # :
Thanks man. Very useful to those of us who need to knock out lots of different blogs...