post

Useful WordPress, Genesis, & Thesis Directory and URL (HTTP) PHP Constants

When creating WordPress plugins, themes, or tweaking plugins, themes, functions.php, you will often need to reference files and folders throughout the WordPress installation. Since WordPress 2.6 (if they are pre-2.6, then use die();), users have had the ability to move this directory anywhere they want, so you always want to avoid hardcoding so that the code is re-usable, especially with plugins. WordPress has defined a set of PHP CONSTANTS (by the way, constants are always UPPERCASE) to store the path to the wp-content and plugins directories. You can use these CONSTANTS in your plugins, child themes or functions.php for any paths you need regardless of where the actual directory might exist on the server.

  • WP_CONTENT_URL: Full URL to wp-content
  • WP_CONTENT_DIR: The server path to the wp-content directory
  • WP_PLUGIN_URL: Full URL to the plugins directory
  • WP_PLUGIN_DIR: The server path to the plugins directory
  • WP_LANG_DIR: The server path to the language directory

You can set your own CONSTANT_DIR by (as a reminder, constants are always UPPERCASE):

define('CONSTANT_DIR', ABSPATH . 'wp-content'); //sets DIR

You can set your own CONSTANT_URL by (as a reminder, constants are always UPPERCASE):

define('CONSTANT_URL', get_option('siteurl').'/wp-content/'); //sets URL

For GENESIS Users, some CONSTANTS of interests are:

  • STYLESHEETPATH: /…/…/…/…./…/…/wp-content/themes/child_theme
  • TEMPLATEPATH: /…/…/…/…./…/…/wp-content/themes/genesis
  • PARENT_URL: get_bloginfo(‘template_directory’): e.g., http://domain.com/wp-content/themes/genesis
  • CHILD_URL: get_bloginfo(‘stylesheet_directory’): e.g., http://domain.com/wp-content/themes/child_theme
  • PARENT_THEME_VERSION: refers to the Genesis version running
  • PARENT_THEME_NAME = ‘Genesis’
  • GENESIS_LANGUAGES_URL (sets to Genesis Library for Child Themes)

For THESIS (1.8) Users, some CONSTANTS of interests are:

Are there any CONSTANTS that are used quite often that I missed?

post

My Current Thoughts on Genesis Framework

design-settings.png

Genesis is a phenomenal framework and has my utmost respect. And as Brian Gardner has stated previously, it is difficult to compare Genesis and Thesis because they have different purposes. The main primary one was that of audience and focus. Thesis aimed to give people an engine and a blank theme while Genesis sought to bring solidarity to all their themes for their customers (which has many exponential benefits! including some similar to SaaS). More simply, Thesis was aimed at everyone as a Do-It-Yourself giving control and the ability to easily customize to the owner/creator while Genesis was designed as an engine for their customer-base. However, they both are frameworks and one cannot help but to compare them (as with the other frameworks). Two of the greatest advantages of Genesis are (1.) their universal AND in-post layout options and (2.) the parent/child theme concept. Chris Pearson and Thesis developers and designers have really missed a phenomenal opportunity to present Skins for Thesis. Because of these two components alone, Genesis is poised to overtake Thesis, and personally with a team of developers at StudioPress, I believe it won’t be long before StudioPress’s Genesis Framework will surpass Thesis in functionality. Yet, with WordPress 3.0 coming soon, I wonder what will happen with this friendly battle between the two frameworks, the two competitors. Furthermore, will StudioPress and Genesis decide to begin to target the general audience as a DIY type theme? Or will they continue to only focus on developers and designers who use StudioPress to design sites for customers?

However, Genesis has room for improvement. The most obvious one is the design part that Thesis has but is currently in development by Brian Gardner. As I mentioned in another previous post, I wished that Thesis would have included some more features in their latest release but did not. They are:

  1. Advanced Feature Box Controls & Options*
  2. Customizable & Integrated Navigation Menu
  3. Mobile Features
  4. Multiple Custom Page Layouts & Options*

Genesis has already addressed the multiple custom page layouts and options, and they have no need for the advanced feature box controls and options with the development of dynamic content gallery that fits so well within Genesis (post coming soon…but see this one here). However, I personally believe that iThemes has revealed one of the biggest gaps in these two frameworks with its development of their Mobile on pluginbuddy.com. So I would love to see a mobile plugin from StudioPress (or as part of the Genesis Core, which I personally was shocked that it wasn’t) that utilizes or can utilize the elements from the associated child theme or that gives three, four or five basic mobile themes that can be selected and even customized in the Genesis admin. The other element that I wanted to see more development around was a more customizable menu system; however, with the announcement and the upcoming release of WordPress 3.0, it probably was a wise decision to leave that where they developed it.

Another idea that I had was in its Theme Settings, under General Settings, I personally would love to see a simpler way to have a linked imaged header, so when imaged header is chosen, then a few options would appear allowing the user to select whether they wanted it to be linked to the home page (front page, or posts page) and the absolute URL of the imaged header (though the Child Themes take care of this to a very small degree).

Beyond these upgrades, the only other core upgrade that I would like to see is with the comments. As it currently stands, no one really deals with comments except through plugins, etc. However, I would have liked Genesis to have threaded comments with some CSS design options (e.g., one basic option that would set the admin/site owner or specified members apart from the normal commentors by coloring their comments a contrasting color already used in the Child Theme) that can utilize OpenID, Twitter, Yahoo!, Google, and Facebook logins. There are several plugins that can accomplish these for you but to have it all in one in the core would be exceptional.

For the SEO, as with Thesis, it would be great to have the option to specify SEO options for categories and tags (and any other custom taxonomy or post type). However, unlike Thesis, Genesis has some great options in its Theme Settings that Thesis does not have, such as the secondary navigation (which is a great way to optimize the taxonomies, and it may be helpful for some to have this as a vertical menu system that stands above the left or right sidebar as the user chooses [if chosen]), primary navigation extras on the right, and category inclusion/exclusion (which I love!). However, with Thesis 1.7, Chris Pearson added the Manage Options Page where one can import and export the theme settings easily for transporting them from blog to blog, installation to installation so now the Import/Export Plugin is no longer needed. And Genesis also has a lot of Options that should have the ability to be saved and exported and imported. While it already has the reset option on each page, there is not a Master Reset option.

And finally, Brian Gardner is developing a Genesis Design Options page which will be able to have rounded corners, very 2.0; however, the only things I see that can improve this are: (1) a color picker! (2) possibly some dynamic sample text to the right of the h1, h2, h3 tags when depicting the size in pixels (and can it do other measurements like em?), (3) a preview button as with the Purchase theme section, and finally (4) a revision part so I can revert back to whatever if I don’t like something or accidentally changed something (typing wrong hex#).

So in summary, I’d like to see the following in future Genesis upgrades:

  1. Mobile Compatability
  2. More Customizable Menu (but waiting for 3.0 to see where that may take you)
  3. Easier Linked Image Header
  4. Comment System Upgrade (CSS)
  5. SEO for Categories, Tags, etc.
  6. Secondary Navigation as a Vertical Menu System
  7. Options Import/Export Page
  8. Design Options Improvement
  9. Add a link in the Genesis admin section that opens a new tab to the Support forums
post

Posting on Two Different Pages When Using a Static Front Page

On one of my sites using Thesis, I wanted to create the WordPress blog so that I can “blog” on two different pages (in my case I wanted a blog blog and a podcast blog) based on categories with a static home page. So I first go to /wp-admin/options-reading.php and select static page and select my front page (Create New Page called Home) and my posts page (Create New Page called Blog). If you want two different blogs then your post page could be something like Blog1.

Since WordPress defaults to one certain page (the posts page) to be able to have it default to two different pages, we will be using Categories to control which posts go where. For example, blog posts (with multiple categories) to one page and my podcast posts (via podpress, with only 2 categories) to another page (called Podcasts).

I use categories for my blog and have two categories (podcast and something else) that I exclude from my blog (or posts page) and create a custom category page (Thesis Tutorial – Creating Custom Categories – Sugarrae) for podcasts (or you can use custom_functions.php to create a custom page with its own CSS, etc). You can use the Front Page Excluded Categories or Simply Exclude or Front Page Category (inclusion method) plugin if your blog is your front page (which here we are using a static page) or you can refer to the WordPress Functions Reference (Function Reference/query posts WordPress Codex) which tell you how to Exclude Posts Belonging to Only One Category (Show all posts except those from a category by prefixing its ID with a ‘-’ (minus) sign) by using the php code query_posts('cat=-3'); manually.

To remove the Podcasts & Podcasts ShowNotes (categories) posts, I added this code to my custom_functions.php

//exclude category from the posts page
function exclude_category($query) {
 if ( $query->is_posts_page) {
 $query->set('cat', '-324, -20');
 }
return $query;
}

add_filter('pre_get_posts', 'exclude_category'); 

is_posts_page (Function Reference/WP Query WordPress Codex says it is available for wp-query) works! The category IDs (-324, -20) can be found when you go to /wp-admin/categories.php and hover over the category, you will see /wp-admin/categories.php?action=edit&cat_ID=XXX at the bottom (in Firefox), or if you click on the category, you will see this in the URL. You want the cat_ID number. The (-) tells the query to exclude the category. So you would replace my numbers 324 and 20 with your category number(s). If you have only one category, it will look like this: $query->set('cat', '-XXX'); but if you have two it will look like this:$query->set('cat', '-XXX, -XXX'); and if you have three it will look like this: $query->set('cat', '-XXX, -XXX, -XXX');.

This creates the Blog posts correctly. Now to create the second one, there are two methods: (1) Custom Category Page (see Sugarrae’s Creating Custom Categories) or (2) Custom Page (see DIY’s Custom Page tutorial). The easier option is to use the custom categories (usually renders a url of domain.com/category/podcasts/), but the sweeter way is the Custom Page.

I hope this helps!

post

2 Sites, 2 Themes, 2 Frameworks: Thesis and Genesis

Less than 6 months ago, I made a decision that I wanted to switch from “normal” themes to the more robust and well-known Thesis theme. However, in reading and studying about Thesis theme, I discovered the development of the Genesis theme from StudioPress. Then I came across several others (9 Frameworks, 10 Frameworks for Designers, other sources: here). They are:

  1. Thematic: Free, Demo
  2. Hybrid:  Free, Demo
  3. Vanilla: Free, Demo
  4. WP Framework: Free, Demo
  5. Whiteboard: Free
  6. Headway: Premium
  7. Sandbox: Free
  8. Carrington: Free, Demo
  9. Thesis: Premium, Demo
  10. Buffet: Free
  11. Genesis: Premium
  12. OnePress Community: Free, Demo
  13. Ashford: Free, Demo
  14. Biblioteca: Free
  15. Simon WP Framework: Free
  16. WordPress PSD Framework: Free

Some good comparisons are: (1) Thematic, Hybrid, & Carrington; (2) Thematic, Hybrid, WP Framework, Whiteboard, Sandbox, & Buffet; (3) Thesis, Thematic, Headway, & Hybrid; and (4) Thesis and Genesis.

So I purchased Thesis. Then somehow, I won a copy of Genesis. Now I am using both. I have placed Genesis on my wife’s blog (which I author on as well) and Thesis on mine (solely). Even though the post comparing Thesis and Genesis was written by one of the creators of Genesis, it is a balanced blog post that seems to be right on and rather modest. In this post, Brian discusses the main differences between Thesis and Genesis. The main primary one was that of audience and focus. Thesis aimed to give people an engine and a blank theme while Genesis sought to bring solidarity to all their themes for their customers (which has many exponential benefits! including some similar to SaaS). And though I haven’t worked with all the themes by StudioPress, I have noticed that there are a lot of commonalities that run between their themes which made working with their themes easy and convenient (instead of adopting other themes from other “vendors”).

Nathan Rice brings out some of the more distinctive features of Genesis including:

  • We were the first (that I know of) to offer universal AND in-post layout options.
  • We were the first (that I know of) to use the body class as the primary means of changing layouts, leaving your markup almost completely unchanged.
  • We were the first to fully embrace the WordPress 2.9 image functions, ditch TimThumb, and use WP thumbnails exclusively.
  • We were the first (major) commercial theme developer to embrace the parent/child theme concept.
  • We were the first to offer child themes for preview/purchase within the dashboard.

Of these “firsts,” my favorite is the first two: offer universal AND in-post layout options and use the body class as the primary means of changing layouts, leaving your markup almost completely unchanged. This is something that I would have loved to seen in Thesis (though it can probably be done programatically if you know PHP, which I am slowly learning). So while I have more than just these two sites, I love working on these two the most.

Fast WordPress Hosting