• Howdy! I’ve been downloading and breaking down the code in themes to find out how they are put together so I can learn how to build my own. Some of the themes are very basic and some are very Advanced(it seems). The question I have is about the advanced themes. I understand that you can create your own options page in the admin area, which is a nice feature. However, it seems to me that some of the themes just throw some PHP code into the functions file, to make it look advanced and it really doesn’t go anywhere except in a big circle that may actually cause more calls to be made than necessary. For instance, in one them they define the template name the paths to all of the template folders like so.

    // Theme
    define('THEMENAME','Theme Name');
    define('THEMENAMESHORT','Short Theme Name');
    // names and stuff
    define('SITENAME',get_bloginfo('name'));
    define('RSSURL',get_bloginfo('rss2_url'));
    define('ACTIVATED', $_GET['activated']);
    // Define directory constants
    define('INC', TEMPLATEPATH . '/inc');
    define('CSS', TEMPLATEPATH . '/css');
    define('JS', TEMPLATEPATH . '/js');
    define('SNIPS', TEMPLATEPATH . '/snips');
    // Define folder constants
    define('ROOT', get_bloginfo('template_url'));
    define('CSS_FOLDER', ROOT . '/css');
    define('JS_FOLDER', ROOT . '/js');
    define('IMAGE_FOLDER', ROOT . '/images');

    And this goes in the header:

    <link rel="stylesheet" href="<?php echo CSS_FOLDER.'/reset.css';?>" type="text/css" media="screen" />
    	<link rel="stylesheet" href="<?php echo CSS_FOLDER.'/wp.css';?>" type="text/css" media="screen" />
    	<link rel="stylesheet" href="<?php echo ROOT.'/style.css';?>" type="text/css" media="screen" />

    When all is needed is to use what WordPress has built in.
    Like this:

    <title><?php wp_title('&laquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title>
    		<link rel="shortcut icon" type="image/x-icon" href="<?php echo get_option('home'); ?>/favicon.ico" />
    		<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    		<!--[if IE 7]><link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/ie.css" type="text/css" media="screen" /><![endif]-->
    <script src="<?php bloginfo('template_url'); ?>/js/animate.js" type="text/javascript"></script>

    I’m mean really. Isn’t that just a long way around to the same path?
    Thanks for your thoughts.

Viewing 7 replies - 1 through 7 (of 7 total)
  • I would assume the idea is that if you’ll ever need to change the path you only change it one place. Maybe it has some use for themes inside a theme, other than that I don’t know how useful it is in WordPress.

    Thread Starter tsalagi

    (@tsalagi)

    I think I know why now. It’s a standard setup for creating several themes with the same markup. Like nebulus said. It helps make it easier to change values in one place rather than through out the markup.

    Thread Starter tsalagi

    (@tsalagi)

    Now for some more code. Some themes have simple code in them but some have code like the following.
    The time date stamp with author links.
    the_time(__('M jS, Y','themename')); ?> | <?php _e('By','themename');?> <?php the_author_posts_link('namefl'); ?> | <?php _e('Category:','themename');
    The content with read more link.
    the_content("<p class=\"serif\">" . __('Read the rest of this page', 'themename') ." &raquo;</p>");
    And the link to pages.
    wp_link_pages("<p><strong>" . __('Pages', 'themename') . ":</strong>", '</p>', __('number','themename'));
    Can someone tell me what does the purpose of including the area where themename is? Doesn’t WordPress resolve what categories and pages are for what theme? I appreciate the help.

    string $domain Unique identifier for retrieving translated strings

    http://codex.wordpress.org/Function_Reference/_e
    http://codex.wordpress.org/Function_Reference/_2

    Thread Starter tsalagi

    (@tsalagi)

    Two usages for the same thing! That’s interesting. So using two underscores will return the same result as using one underscore with an e. The explanations make sense but having two different functions does not. Thanks for following me on this nebulus.

    The explanations make sense but having two different functions does not

    The two functions are used in very different ways:

    <?php _e('Boo!);?> is a simple echo

    <?php my_function(__('Boo') );?> passes a text string to a function.

    Thread Starter tsalagi

    (@tsalagi)

    Ahh very good! Maybe the codex should reflect such simple but clear explanations. The more I learn the less I know. Now, just for the fun of it and to learn something new, I have to look into how that can be used in a function. It’s never ending. I’ll never get my blog built, but I’ll know a lot about WordPress. LOL.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Advanced Themes Functions and Other Code’ is closed to new replies.