KLoning Spoon

WordPress Constants

There a few helpful constants defined in WordPress for theme developers. TEMPLATEPATH is defined as get_template_directory(), and STYLESHEETPATH is defined as get_stylesheet_directory().

The function call and the constant are actually interchangeable with each other, but by using the constants (TEMPLATEPATH & STYLESHEETPATH) rather than the functions each time, you’ll reduce the amount of database queries and speed up your site.

TEMPLATEPATH

This returns the path to the template files of a theme. If a child theme is activated, this path will still point to the parent theme. An example path would be “/var/www/html/mysite/wp-content/themes/parenttheme”. You would most likely use this call to include a file. Example code in the functions.php file:

// Create Theme Options Page
require_once(TEMPLATEPATH . '/extensions/theme-options.php');

bloginfo(‘template_directory’);

bloginfo(‘template_directory’) returns the URL of the template directory. An example of this would be “http://mysite.com/multisite1/wp-content/themes/parenttheme”. This could be used to call a stylesheet or an image file. If a child theme is activated, this still returns the parent template directory. Example code in the header.php file:

<!--[if IE 6]>
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo('template_directory'); ?>/css/ie6.css" />
<![endif]-->

STYLESHEETPATH

This returns the stylesheet path to the template files of a theme. If a child theme is activated, this path will point to the child theme directory. An example path would be “/var/www/html/mysite/wp-content/themes/childtheme”. You would most likely use this call to include a file that you are sure is present in a child theme, or to check if it is. Example code in the functions.php file:

// Create Theme Options Page for the Child Theme
require_once(STYLESHEETPATH . '/extensions/theme-options.php');

get_bloginfo(‘stylesheet_directory’)

bloginfo(‘stylesheet_directory’) returns the URL of the child template directory. An example of this would be “http://mysite.com/multisite1/wp-content/themes/childtheme”. This could be used to call a stylesheet or an image file in a child theme. Example code in the header.php file:

<!--[if IE 6]>
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo('stylesheet_directory'); ?>/css/ie6.css" />
<![endif]-->

Define Your Own Constants

If your theme required a lot of calls to get_bloginfo(‘stylesheet_directory’), you should define this as a new constant to reduce database calls and make your code easier to read. To do this, place the following snippet in your functions.php file (it works in child themes as well):

define('STYLESHEET_DIR', get_bloginfo('stylesheet_directory'));

To retrieve the URL, you can use this anywhere in your theme:

<?php echo STYLESHEET_DIR; ?>

In this tutorial, we’ll show you how to add column shortcodes to your Wordpress theme. In the end, we also cover how to convert this into a column-layouts plugin.

Textmate theme to Notepad++ styler is a program that tries to translate Textmate themes ( .tmTheme ) into Notepad++ style ( styler.xml ).

The Specials Board theme includes .seestyle files for all programming  languages that Coda supports out of the box. Not just Ruby, PHP, XHTML, CSS and the others referenced in the demo screencaps, but ASP, Python, Smarty, Action Script, Java and all the others.

The Specials Board theme includes .seestyle files for all programming languages that Coda supports out of the box. Not just Ruby, PHP, XHTML, CSS and the others referenced in the demo screencaps, but ASP, Python, Smarty, Action Script, Java and all the others.

The WordPress Theme Files Execution Hierarchy

The WordPress Theme Files Execution Hierarchy

First create a functions.php for your child theme and add

// Show Wp-PageNavi when it's active function twentyeleven_child_content_nav( $nav_id ) { global $wp_query; if ( $wp_query->max_num_pages > 1 ) : ?> <?php /* add wp-pagenavi support for posts */ ?> <?php if(function_exists('wp_pagenavi') ) : ?> <?php wp_pagenavi(); ?> <br /> <?php else: ?> <nav id="<?php echo $nav_id; ?>"> <h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3> <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentyeleven' ) ); ?></div> <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentyeleven' ) ); ?></div> </nav><!-- #nav-above --> <?php endif; ?> <?php endif; }

Next copy index.php to your child theme folder and change line 31 to
<?php twentyeleven_child_content_nav( 'nav-below' ); ?>

If wp-pagenavi is installed it will show it, if it isn’t, it’ll show the default next/previous

I’m trying to build wordpress theme with jQuery Mobile. But it’s always give an error when i tried to open any link. It’s keep give me loading and an error in the end.

After an hours finnaly i know what thats keep me wrong. That i’m not putting rel=”external” on the link that created by theme. So, i just give an jQuery function to add this rel on every link instead I manually add to all the file of the theme.

$(document).ready(function(){$("a").attr("rel","external");});

And viollaaa, now every link it works like a charm, Alhamdulillah.

Basiic WordPress Theme Featuring modern jQuery Powered Sliding Gallery, and theme options page. Compatible for WordPress 3.2

Basiic WordPress Theme Featuring modern jQuery Powered Sliding Gallery, and theme options page. Compatible for WordPress 3.2

Free, Clean, Minimal, Nostalgic, Simple, Sophisticated, Whimsical Wordpress Theme: Liquorice

Free, Clean, Minimal, Nostalgic, Simple, Sophisticated, Whimsical Wordpress Theme: Liquorice