Wordpress Codex
“The WordPress Codex was founded to revitalize the collaborative documentation effort of WordPress…”
Portfolio – WPESP Theme uses such documentation and several tutorials to acquire its potential. The code is commented with links to the Codex de WordPress o a los tutoriales, or the tutorials, as shown in the following example of the index.php file.
if (is_category(work) or is_category(featured)): // Category Work // http://codex.wordpress.org/Conditional_Tags#A_Category_Page include(TEMPLATEPATH . '/category-work.php'); elseif( in_category(3) ) : // Post in Category Work(in our case ID 3) - View Case Study // http://codex.wordpress.org/Conditional_Tags#A_Category_Page // http://codex.wordpress.org/Template_Tags/in_category#Use_OUTSIDE_The_Loop include(TEMPLATEPATH . '/work.php'); endif if(is_page(about)) : // Page About | http://codex.wordpress.org/Conditional_Tags#A_PAGE_Page include(TEMPLATEPATH . '/about.php'); elseif(is_page(contact-us)) : // Page Contact include(TEMPLATEPATH . '/contact.php'); endif
Some of the pages created for this theme are shown in the previous code, and will be commented on together with other ones.
Index.php
It is the main file. It names different files according to the established parameters.
Category-Work.php
It is activated when the categories Featured and Work are marked, and is where the pieces of work for Home should be. All pieces of work must use the Work category, including the featured piece of work, which will be Featured. In the Featured category, Work must be marked as Category Parent.
Work.php
It corresponds to the page View Case Study, this is, the page of each piece of work. As mentioned in Category-Work.php, the pieces of work should use the Work category. In Work.php we mark the posts that belong to the Work category, which corresponds to ID=3 in the Demo.
About.php
It corresponds to the page About. Some features shared by this file and Contact.php will be explained when the functions are discussed.
Contact.php
It corresponds to the page Contact. WPESP Portfolio Theme uses the cformsII plugin to show the form.
You should edit the cform.php file of the plugin to show the text (Required) after the label. This process should be repeated each time the plugin is updated.
Edit process for cform.php:
Look for the following code, cut it…
### adding "required" text if needed
if($field_emailcheck == 1)
$content .= '<span class="emailreqtxt">'.stripslashes($cformsSettings['form'.$no]['cforms'.$no.'_emailrequired']).'</span>';
else if($field_required == 1 && !in_array($field_type,array('ccbox','luv','subscribe','checkbox')) )
$content .= '<span class="reqtxt">'.stripslashes($cformsSettings['form'.$no]['cforms'.$no.'_required']).'</span>';
… and paste it after this one.
### print label only for non "textonly" fields! Skip some others too, and handle them below indiv.
if( ! in_array($field_type,array('hidden','textonly','fieldsetstart','fieldsetend','ccbox','luv','subscribe','checkbox','checkboxgroup','send2author','radiobuttons')) )
$content .= $nttt . '<li'.$liID.$liERR.'>'.$insertErr.'<label' . $labelID . ' for="'.$input_id.'"'. $labelclass . '><span>' . stripslashes(($field_name)) . '</span></label>';
Home.php
Index.php appears as “main” in the previous section, because Home.php is the file that configures the homepage.
“When the page is being displayed as the homepage, if a Page Template with the filename home.php exists for your active Theme, the Plugin will override the Page’s set Page Template and use home.php instead.”
Functions.php
Following the guidelines of the tutorial How You Can Use WordPress Functions to Run a Smarter Blog, the functions have been placed in different files and have been included in this file.
Portfolio_Panel.php
This file is used so as the code is not re-written in the files Home.php and Category-Work.php.
The description in Portfolio_Panel.php should be written in the Excerpt of the administration panel in the working post. The rest of the data are added as a normal post, using the Custom Write Panel created for WPESP Portfolio Theme. This last topic will also be discussed.
<?php the_excerpt(); ?>
As shown in the comment "// Featured Category (in our case id=5)” of the following code, you should edit the file so that it corresponds with the category Featured of your portfolio.
<?php if (in_category(5)):
// Featured Category (in our case id=5) ?>
<img class="new" src="< ?php echo get_option('home'); ?>/wp-content/uploads/new.png" width="66" height="28" alt="New!" />;
< ?php endif ?>
It will be included using the code:
<?php portfolio_panel() ?>
This file contains the code that corresponds to the card of the pieces of work. The result of the front-end is the one shown on the image at the right side.
Portfolio_hCard.php
Just as the Portfolio_Panel.php, it is used to put a same code in different files. In this case it corresponds to hCard of #sidebar of About.php and Contact.php.
It will be included using the code:
<?php portfolio_hcard() ?>
Portfolio_Custom-Write-Panel.php
This function is different from the previous ones. In this case, it is a plugin that affects the administrator, and has been created according to the proposal in the tutorial Creating Custom Write Panels in WordPress. The function creates two new drop-down menus in the administrator panels, one in posts and the other one in pages.
Portfolio Post Settings:
It corresponds to the first example mentioned, where the different Custom Fields used to create the portfolio are integrated.
hCard Post Settings:
It corresponds to the second example, where the different Custom Fields used to create the hCard that will appear in pages About and Contact are integrated.
As shown in the comment “// If is About (in our case id=5) or Contact (in our case id=89) page” of the following code, you should edit the file so it corresponds to the pages of your portfolio.
foreach($hcard_meta_boxes as $meta_box) {
if ($post->ID == 5 or $post->ID == 89) {
// If is About (in our case id=5) or Contact (in our case id=89) page
$meta_box_value = get_post_meta($post->ID, $meta_box['name'].'_value', true);






25-12-2008 at %I:%M %p