Wednesday, August 29, 2012

WordPress Theme Tricks – WordPress Options

There are many built-in options in the Admin panels that can make your site much nicer. Here are some of them: Custom Frontpage By default, WordPress displays your blog posts on the frontpage. But if you want to have a static page (ie. welcome or splash page) instead, you can set that in Admin > [...]


The post WordPress Theme Tricks – WordPress Options appeared first on Tutorial Mini.


Related posts:

  1. WordPress Theme Tricks – Query Posts

  2. WordPress Theme Tricks – Custom Fields

  3. WordPress Theme Tricks – Unique Category template






via Tutorial Mini http://tutorialmini.com/wordpress-theme-tricks-wordpress-options/

WordPress Theme Tricks – Page Template

If you are using WordPress as a basic webpage management, you better don’t miss out the Page Template feature. It allows you to customize how the Pages should be displayed. To use Page Template, first you need to create a Page Template, then you can assign the Page to specific template. Here is how the [...]


The post WordPress Theme Tricks – Page Template appeared first on Tutorial Mini.


Related posts:

  1. WordPress Theme Tricks – Unique Category template

  2. WordPress Template Hierarchy

  3. WordPress Theme Tricks – Query Posts






via Tutorial Mini http://tutorialmini.com/wordpress-theme-tricks-page-template/

WordPress Theme Tricks – WP List Pages

Template tag wp_list_pages is commonly used to display a list of WP Pages in the header and sidebar for navigation purpose. Here I will show you how to use wp_list_pages to display a sitemap and sub-menu. Site map To generate a sitemap (sample) of all your Pages, put this code in your sitemap Page Template [...]


The post WordPress Theme Tricks – WP List Pages appeared first on Tutorial Mini.


Related posts:

  1. WordPress Theme Tricks – Query Posts

  2. WordPress Theme Tricks – Unique Category template

  3. WordPress Theme Tricks – Display Google Ad after the first post






via Tutorial Mini http://tutorialmini.com/wordpress-theme-tricks-wp-list-pages/

WordPress Theme Tricks – Custom Fields

Custom field is one the most powerful WordPress features. It allows you to attach extra data or text to the post along with the content and excerpt. With Custom Fields, you can literally trun a WordPress into any web portal CMS. First add the Custom Field in the post. To display the article image and [...]


The post WordPress Theme Tricks – Custom Fields appeared first on Tutorial Mini.


No related posts.



via Tutorial Mini http://tutorialmini.com/wordpress-theme-tricks-custom-fields/

WordPress Theme Tricks – Query Posts

You can use query_posts to control which posts to show up in The Loop. It allows you to control what content to display, where to display, and how to display it. You can query or exclude specific categories, so you get full control of it. Here I will show you how to use query_posts to [...]


The post WordPress Theme Tricks – Query Posts appeared first on Tutorial Mini.


Related posts:

  1. WordPress Theme Tricks – Unique Category template

  2. WordPress Theme Tricks – Display Google Ad after the first post

  3. WordPress Theme Tricks – WordPress Conditional Tags






via Tutorial Mini http://tutorialmini.com/wordpress-theme-tricks-query-posts/

WordPress Theme Tricks – Display Google Ad after the first post

How to display a Google ad after the first post? It is very simple. You just need to add a variable ($loopcounter) in The Loop. If the $loopcounter is less than or equal to 1, then include google-ad.php code. [crayon-503e319401856/] This is a part of WordPress Theme Tricks tutorial.


The post WordPress Theme Tricks – Display Google Ad after the first post appeared first on Tutorial Mini.


Related posts:

  1. WordPress Post Types and Taxonomies – Displaying Post Types

  2. WordPress Theme Tricks – WordPress Conditional Tags

  3. The Anatomy of a WordPress Theme – Dynamic Content






via Tutorial Mini http://tutorialmini.com/wordpress-theme-tricks-display-google-ad-after-the-first-post/

WordPress Theme Tricks – Unique Category template

Suppose you want to use different Category template to display specific category. Simply save your Category template as category-2.php (note: add “-” and the categoryID number to the file name). So, category-2.php will be used to display categoryID 2, category-3.php will be used for categoryID 3, and so on. This is a part of WordPress [...]


The post WordPress Theme Tricks – Unique Category template appeared first on Tutorial Mini.


Related posts:

  1. WordPress Theme Tricks

  2. WordPress Theme Tricks – WordPress Conditional Tags

  3. WordPress Template Hierarchy – Template hierarchy in details






via Tutorial Mini http://tutorialmini.com/wordpress-theme-tricks-unique-category-template/

WordPress Theme Tricks – WordPress Conditional Tags

Conditional Tags are very useful when creating a dynamic WordPress theme. It allows you to control what content is displayed and how that content is displayed. Here are couple sample uses of Conditional Tags: Dynamic Highlight Menu Here is what I used to create a dynamic highlight menu. In the first list item, if it [...]


The post WordPress Theme Tricks – WordPress Conditional Tags appeared first on Tutorial Mini.


Related posts:

  1. WordPress Theme Tricks

  2. The Anatomy of a WordPress Theme – Debug and Validate After Composing a Theme

  3. The Anatomy of a WordPress Theme – Theme Location






via Tutorial Mini http://tutorialmini.com/wordpress-theme-tricks-wordpress-conditional-tags/

WordPress Theme Tricks

WordPress was originally created as a weblog or blog platform. But now WordPress has grown so powerful that you can use it to create any type of website and use it as a Content Management System (CMS). In this article, I’m going to share some of my WordPress tricks with you on how to make [...]


The post WordPress Theme Tricks appeared first on Tutorial Mini.


Related posts:

  1. The Anatomy of a WordPress Theme – Theme Files and Typical File Structure

  2. The Anatomy of a WordPress Theme – Theme Location

  3. The Anatomy of a WordPress Theme – Debug and Validate After Composing a Theme






via Tutorial Mini http://tutorialmini.com/wordpress-theme-tricks/

Tuesday, August 28, 2012

WordPress Post Types and Taxonomies – Using Post Types and Taxonomies

Now that we have the nuts and bolts, I think “Why do I care about these things?” is a really fair question. The possibilities with post types and taxonomies, especially working with clients that are often too busy to manage the intricacies of a site, is endless. This, in my opinion, saves time over creating new admin functions and updating plugins, and opens doors to new possibilities with much less work (and coding) involved.


Below are some ideas that I had about how to integrate these into actual work:



  1. Review Sites

    First, a review site could benefit from the custom templating options listed above (single and archive).

    Here are some more post types and taxonomies that you could implement on a review site:

    • Post Type – Movie Reviews

    • Taxonomies – Genre, Actor, Director

    • Post Type – Book Reviews

    • Taxonomies – Genre, Author, Publisher

    • Post Type – Product Reviews

    • Taxonomies – Product Category, Price



  2. Real Estate Listing Sites

    While there are some good templates for real estate listing sites, post types and taxonomies let creative people make custom templates that can easily be maintained by clients and webmasters alike. Here are just a few ideas to use in your next project:

    • Post Type – Listings

    • Taxonomies – Area, Agent, Price, Rooms

    • Post Type – Agents



  3. Event Listings

    One thing that WordPress really lacks (in my opinion) is a good event management system. Post types and taxonomies could easily take care of that by offering a system to classify monthly events by location, day, or any other system you can think of.

  4. Subscription Sites

    With the creation of a new post type and template, you could create a custom, premium category for your blog or website and integrate a payment gateway to create your very own membership site.

  5. E-commerce

    By creating a product post type and template, you could easily add and display products for sale on your site. In addition, taxonomies would allow for easy product organization.


This is a part of WordPress Post Types and Taxonomies tutorial.



The post WordPress Post Types and Taxonomies – Using Post Types and Taxonomies appeared first on Tutorial Mini.


Related posts:



  1. WordPress Post Types and Taxonomies

  2. WordPress Post Types and Taxonomies – Integrating Post Types

  3. WordPress Post Types and Taxonomies – Displaying Post Types






via Tutorial Mini http://tutorialmini.com/wordpress-post-types-and-taxonomies-using-post-types-and-taxonomies/

WordPress Post Types and Taxonomies – Displaying Taxonomies

There are currently three primary ways to display custom post types in your themes:



  • Taxonomy Cloud

  • Custom Taxonomy Query

  • Custom Taxonomy List


Taxonomy Cloud


Just as there are tag clouds, there are taxonomy clouds. To make it easy, both tags and clouds use the wp_tag_cloudfunction. In order to display an array of taxonomy categories in a cloud, we would use the following code:



<?php
wp_tag_cloud( array( 'taxonomy' => 'taxonomy_name_1','taxonomy_name_2' ) );
?>

Custom Taxonomy Query


Taxonomies can also be included in custom queries just like we did with post types above. For example, to display content from the taxonomy movie_genre, we would need to insert the following code into our template file:



$args = array(
'tax_query' => array(
'taxonomy' => 'movie_genre',
'field' => 'slug',
'terms' => 'comedy'
)
);
query_posts( $args );

First, we use the argument tax_query so that we can pass parameters that will allow us to query by slug or terms and return more accurate query results. In this example, we displayed posts tagged as “comedy” within the custom taxonomy “movie_genre”. Once again, like we did with post types, we can limit the number of posts that this query returns.


Custom Taxonomy Lists


To display a comma-delineated list of posts by taxonomy, we simply need to put the following somewhere in the loop:



<?php the_terms( $post->ID, '{taxonomy name}', '{Displayed Title}: ', ', ', ' ' ); ?>

This is a part of WordPress Post Types and Taxonomies tutorial.



The post WordPress Post Types and Taxonomies – Displaying Taxonomies appeared first on Tutorial Mini.


Related posts:



  1. WordPress Post Types and Taxonomies – Displaying Post Types

  2. WordPress Post Types and Taxonomies – Integrating Taxonomies

  3. WordPress Post Types and Taxonomies – Integrating Post Types






via Tutorial Mini http://tutorialmini.com/wordpress-post-types-and-taxonomies-displaying-taxonomies/

WordPress Post Types and Taxonomies – Integrating Taxonomies

Overall, taxonomies are pretty easy to implement in your functions.php file. Remember, you can go hierarchical with them or treat them like tags, so the more complex you want the greater the difficulty. Either way, here is a quick rundown of how to incorporate these into your theme.


Again, open up your functions.phpfile and insert the following code:



function movie_taxonomy() {
register_taxonomy(
'movie_review',
'mysite_reviews',
array(
'hierarchical' => true,
'label' => 'Movie Review',
'query_var' => true,
'rewrite' => array('slug' => 'movie-reviews')
)
);
}

add_action( 'init', 'movie_taxonomy' );

To break this down, first we give the taxonomy a formal name (“movie_review”), and we place it under the post type “mysite_reviews”, which we created earlier.



function movie_taxonomy() {
register_taxonomy(
'movie_review',
'mysite_reviews',

Then we pass these values:



array(
'hierarchical' => true,
'label' => 'Movie Review',
'query_var' => true,
'rewrite' => array('slug' => 'movie-reviews')
)

This supplies the following arguments:



  • hierarchical – When set to “true”, the taxonomy will act more like a category. There can be parent taxonomies and nested taxonomies allowing for greater depth of classification. When set to “false”, they act like just like tags.

  • label – As with the post types above, this is the label that the taxonomy will publicly recieve.

  • query_var – When set to “true” this taxonomy becomes a queryable element.

  • rewrite – This sets the URL rewrite. Now posts in this taxonomy will be displayed as http://mysite.com/movie-reviews/{post title}/.


The end result within our admin nav should look like this:


WordPress Admin Navigation With Custom Post Type and Taxonomy

WordPress Admin Navigation With Custom Post Type and Taxonomy



Furthermore, we can dive into that interface and add more classification categories and structure. That interface looks similar to the category interface that you may already be familiar with.


WordPress Custom Post Type Category Screen

WordPress Custom Post Type Category Screen



From this interface, you can edit the slugs of the various categories within your taxonomy, create new categories, and determine parent and child categories.


This is a part of WordPress Post Types and Taxonomies tutorial.



The post WordPress Post Types and Taxonomies – Integrating Taxonomies appeared first on Tutorial Mini.


Related posts:



  1. WordPress Post Types and Taxonomies – Integrating Post Types

  2. WordPress Post Types and Taxonomies – Displaying Post Types

  3. WordPress Post Types and Taxonomies






via Tutorial Mini http://tutorialmini.com/wordpress-post-types-and-taxonomies-integrating-taxonomies/

WordPress Post Types and Taxonomies – Displaying Post Types

Php programming

Php programming (Photo credit: Wikipedia)



Since WordPress post types are simply an extension of the existing classification system, displaying them in a theme is quite similar to what is already in place. There are currently three primary ways to display custom post types in your themes:



  • Post Query

  • Single Post Template

  • Archive Template


Displaying via Post Query


To display the new post type mysite_reviews, you will want to open up the template file that you would like to display it on (in my case, I usually create a custom home.phpfor templates), and enter the following code:



$args = array( 'post_type' => 'mysite_reviews', 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
the_title();
echo '<div class="entry-content">';
the_excerpt();
echo '</div>';
endwhile;

This simply creates a new WordPress loop that will display the title and excerpt from the 10 most recent entries in the mysite_reviews post type.


Displaying via Single Post Template


Just as you can customize the way individual posts are displayed via a theme’s single.php file, you can customize the way your individual post type entries are displayed. The easiest way to do this is to create a duplicate of your theme’s single.php file and rename it to single-{posttypename}.php . From there, you can customize that file to your specs. Using the example from above, we would need a single post template named single-mysite_reviews.php.


Displaying by Archive Template


While this feature will not be available until WP 3.1 releases, post types can also be displayed archive-style by creating a file in your theme named archive-{posttypename}.php. So, if we were creating an archive for the post type, we would create an archive template named archive-mysite_reviews.php and place it within our template folder.


This is a part of WordPress Post Types and Taxonomies tutorial.



The post WordPress Post Types and Taxonomies – Displaying Post Types appeared first on Tutorial Mini.


Related posts:



  1. WordPress Post Types and Taxonomies

  2. WordPress Post Types and Taxonomies – Integrating Post Types

  3. WordPress Template Hierarchy – Template hierarchy in details






via Tutorial Mini http://tutorialmini.com/wordpress-post-types-and-taxonomies-displaying-post-types/

WordPress Post Types and Taxonomies – Integrating Post Types

Integrating post types is simply a matter of including the register_post_type function. Once you have included this in your functions.php file, your nav menu should go from something like this:


Original WordPress Navigation

Original WordPress Navigation



to this:


WordPress Navigation with Custom Post Type

WordPress Navigation with Custom Post Type



In order to create custom post types, open your template’s functions.phpfile in an editor, and place the following function within the file:



function create_post_type() {
register_post_type( 'mysite_reviews',
array(
'labels' => array(
'name' => __( 'Reviews' ),
'singular_name' => __( 'Review' )
),
'public' => true,
'menu_position' => 5,
'rewrite' => array('slug' => 'reviews')
)
);
}

add_action( 'init', 'create_post_type' );

Broken down, this adds the function create_post_type, and registers the post type mysite_reviews.



add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'mysite_reviews',

You may wonder why I’ve named the post_type mysite_reviews, and not just reviews. I made the name more conspicuous in order to make sure that my post type wouldn’t interfere with custom post type names from other plugins or themes.


Here is a summary of the important post type parameters I’ve set above:



  • labels – WordPress allows us to label everything from the post type’s name to the label for adding new posts. A complete list can be found here. In the above function, I labeled the name of the post type and its singular name.

  • public – If set to true

  • menu_position – I set this to 5, which will place the post type directly under “Posts”. The other placements are as follows: null (below Comments), 0 (below Media), 20 (below Pages), 60 (below first separator) and 100 (below second separator)

  • rewrite – So that our actual term “mysite_reviews” doesn’t get put in the URL, we set the slug to “reviews” which will be much better in the long run for our visitors, links, and SEO.


This is a part of WordPress Post Types and Taxonomies tutorial.



The post WordPress Post Types and Taxonomies – Integrating Post Types appeared first on Tutorial Mini.


Related posts:



  1. WordPress Post Types and Taxonomies

  2. WordPress Multisite Network With Multiple Domains

  3. WordPress Excerpts – Replace [...] by the link “Read More”






via Tutorial Mini http://tutorialmini.com/wordpress-post-types-and-taxonomies-integrating-post-types/

WordPress Post Types and Taxonomies

Archives' stacks

Archives’ stacks (Photo credit: dolescum)



When you think of post types, the important word to remember is organization. The post type itself will not add really any functionality, but it allows us to better organize WordPress content and build admin dashboards that are more specific to the type of site that we are working with.


Here are some important things to remember when working with post types:



  • When you create a new post type, a new upper level nav element will appear the main left side admin menu. From there, all of the standard post and page editors are available.

  • The URL string for a new post type will be : http://yoursite.com/{post-type}/{title}/.

  • You can create post type archive pages just like you do with categories, and you can even create special template files by creating an archive-{post-type}.php file.


For other info on integrating post types, querying post types, and overall functions, visit the WordPress Codex.


This tutorial contains :




The post WordPress Post Types and Taxonomies appeared first on Tutorial Mini.


Related posts:



  1. WordPress Excerpts – Replace [...] by the link “Read More”

  2. WordPress Basic – Installing WordPress

  3. WordPress Basic – Installing WordPress – Famous 5-Minute Install






via Tutorial Mini http://tutorialmini.com/wordpress-post-types-and-taxonomies/

Monday, August 27, 2012

WordPress Template Hierarchy – Importance of WordPress Template Hierarchies

English: A screenshot of the WordPress admin i...

English: A screenshot of the WordPress admin interface. (Photo credit: Wikipedia)



Supposing you are implementing the following complex changes “together” like:



  1. Displaying excerpts with thumbnails only on tag pages while serving normal content on date archives and categories (not using excerpt or thumbnail).

  2. Embedding lengthy jQuery slide shows to category pages only but not present on tags or other archive pages.

  3. Displaying different ad networks on categories, tags but no ads on archives.

  4. Displaying unique widgets on each sidebar of these different templates.


All of these changes can be made simpler if you understand template hierarchies in WordPress and directly implementing the changes to the canonical template.


In this case, you have isolated each template completely that makes it easier to implement complex changes specific only to that template. You also save some resources by not relying too much on PHP in serving the content.


The above example is not only limited on archives (tags, categories, etc) but can be implemented in customizing your entire WordPress theme. The key is to identify the canonical template in the hierarchy and make sure you use them in making big changes in your theme.


This is a part of WordPress Template Hierarchy tutorial.



The post WordPress Template Hierarchy – Importance of WordPress Template Hierarchies appeared first on Tutorial Mini.


Related posts:



  1. WordPress Template Hierarchy

  2. WordPress Template Hierarchy – Template hierarchy in details

  3. WordPress Template Hierarchy – Practical Application






via Tutorial Mini http://tutorialmini.com/wordpress-template-hierarchy-importance-of-wordpress-template-hierarchies/

WordPress Template Hierarchy – Practical Application

Archive

Archive (Photo credit: aftab.)



Let’s implement what you have learned from the above template hierarchy details. One of the best application is customizing your themes. For example, supposing your theme only uses archive.php to display the following content:



One limitation of this setup is that there is only one template file to display three different sections of content. If you are going to customize your categories, tags and date archives such that they look differently from each other; then you will rely heavily on WordPress conditional tags to get the result.


This sounds OK for minor theme customization. A typical example is when you are implementing different styles for your H1 header tag for categories, tags and date archives. You can do this by setting different id that can be used by your CSS file in returning specific header tag style. A short PHP script using WordPress conditional tags can be implemented such as shown below:



<?php
if (is_category()) {
//This is category page
echo ‘<h1 id=”categoryheader”>This is your category header</h1>’;
}
if (is_tag()) {
//This is tag page
echo ‘<h1 id=”tagheader”>This is your tag page header</h1>’;
}
if (is_date()) {
//This is a date archive page
echo ‘<h1 id=”datearchive”>This is your date archive header</h1>’;
}
?>

Then in your CSS file (style.css for example), you can customize H1 tags to provide different size of fonts such as:



#categoryheader {font-size:20px;}
#tagheader {font-size:25px;}
#datearchive {font-size:30px;}

But if you are doing massive changes in your theme, then you might need to create the canonical template to make things easier to manage. In this case, you will not be using conditional tags anymore since you can directly coding the changes to the corresponding template file without using PHP.


So how are you going to create the canonical template for each types of content (tags and categories) based on the available archive.php?


Follow the steps below:



  1. Download archive.php to your desktop. Make a backup of it.

  2. Open archive.php using your favourite code editor (notepad will do).

  3. Open another blank file using a text editor.

  4. Copy and paste all the code from archive.php to this blank file.

  5. Save the file as category.php.

  6. Open another blank text file.

  7. Copy and paste all code from archive.php to this file.

  8. Save it as tag.php

  9. Upload both category.php and tag.php back to your WordPress theme directory.

  10. Access your site to see the changes. Go to any archive, categories or tag page, you should see no errors.


Now you have specific template for each sections, its time to implement any massive design or coding changes that are specific to each templates. Using the previous example if you are implementing different styles to your header H1 tags on categories, tags and date archives without using PHP and conditonal tags:


In category.php template only add:



<h1 id="categoryheader">This is your category header</h1>

In tag.php template only add:



<h1 id="tagheader">This is your tag page header</h1>

In archive.php template only (where this is used for generating the date archive content) add:



<h1 id="datearchive">This is your date archive header</h1>

As you can see, you can implement the changes directly to the template file using HTML and not using PHP.


This is a part of WordPress Template Hierarchy tutorial.



The post WordPress Template Hierarchy – Practical Application appeared first on Tutorial Mini.


Related posts:



  1. WordPress Template Hierarchy – Template hierarchy in details

  2. WordPress Template Hierarchy

  3. The Anatomy of a WordPress Theme – Theme Files and Typical File Structure






via Tutorial Mini http://tutorialmini.com/wordpress-template-hierarchy-practical-application/

WordPress Template Hierarchy – Template hierarchy in details

Personalizando WordPress 1.5

Personalizando WordPress 1.5 (Photo credit: juanpol)



WordPress is programmed to interact with your theme files in presenting content to different sections in your site. WordPress core developers devises a template hierarchy to systematize the management of templates.


Think of template hierarchy as an order of importance. Each of the different content section of a WordPress website has its own canonical/official or standard template. For example, single.php is the canonical template when generating blog post content while category.php is the canonical template of WordPress categories. Other canonical templates are summarized on the previous section.


WordPress would be looking for this canonical template first in your theme directory before other templates would be considered.


Below are some example of the most important hierarchies applicable to most WordPress themes (the first one is the canonical template):



  1. Generating blog post:

    • single.php

    • index.php



  2. Displaying home page content:

    • home.php

    • index.php



  3. WordPress page content:

    • page.php

    • index.php



  4. Category content:

    • category.php

    • archive.php

    • index.php



  5. Displaying tags:

    • tag.php

    • archive.php

    • index.php



  6. Author content:

    • author.php

    • archive.php

    • index.php



  7. Search results:

    • search.php

    • index.php



  8. Template to use if the URL is not found (404):

    • 404.php

    • index.php




How to use and understand them?


As discussed previously, WordPress will be looking first for the canonical/official template for displaying content in a specific section of your WordPress site. If its not available (probably because theme developers didn’t use it), WordPress will be looking for the second template file under its hierarchy.


For example, supposing author.php is not available in your themes, WordPress will be using archive.php since this is the second template in the hierarchy.


If archive.php is still not available, it will look for index.php that is the third and the last template in the hierarchy. If still not found; error or a blank page will be returned to the browser.


Another example is when category.php is not available or used by your themes, WordPress will look for archive.php to display category content. It is because archive.php is #2 in the template hierarchy (based on the above list). However if archive.php is also not available, WordPress will look for index.php and use it.


If you are examining the above hierarchies, you will notice that index.php can be used to generate any types of content in your WordPress site (regardless if it is a post, page, tag, categories, etc.) only if all canonical templates are missing. However, this is not a common practice and all themes do have its own specific templates for generating content in different sections of your WordPress site.


This is a part of WordPress Template Hierarchy tutorial.



The post WordPress Template Hierarchy – Template hierarchy in details appeared first on Tutorial Mini.


Related posts:



  1. WordPress Template Hierarchy

  2. The Anatomy of a WordPress Theme – Dynamic Content

  3. The Anatomy of a WordPress Theme – Theme Location






via Tutorial Mini http://tutorialmini.com/wordpress-template-hierarchy-template-hierarchy-in-details/

WordPress Template Hierarchy

English: WordPress Template Hierarchy. עברית: ...

English: WordPress Template Hierarchy. עברית: היררכית התבניות של וורדפרס. (Photo credit: Wikipedia)



This is a useful tutorial for WordPress administrators and beginners in theme development. This talks about WordPress template hierarchy and its application. This topic can be so broad but let’s only talk about its most important implementation that you can use within your own website.


By design, most WordPress themes contain template files for serving content from different sections in your WordPress site. These sections could be your blog post, categories, pages, homepage, tags, author pages, etc.


These template files are found in your WordPress theme directory: /wp-content/themes/theme_name/.


The following are the most important template files for generating content:



  • single.php – template file used by your posts.

  • page.php – used in generating pages (not blog post) in your WordPress site.

  • archive.php – archived pages. Categories and tags are also considered as archives.

  • category.php – template specific for categories.

  • tag.php – specific template for WordPress tags.

  • index.php or home.php – template for generating front page content in your blog.

  • sidebar.php, footer.php, etc. still belongs to the theme files but they are only part of the more important templates mentioned previously.


Most WordPress theme developers have the freedom to decide what templates they are going to use in representing different content sections of your site. For example, it is common to see WordPress themes that only uses archive.php for generating the following WordPress content:



  1. Categories

  2. Tags


So in this type of theme, you cannot see the following template files in your theme directory because they are not being used:



  1. category.php

  2. tag.php


Other example is where you realize home.php is the one being used to generate front page content instead of index.php. In some themes, there is no home.php but instead use index.php in serving home page content.


This tutorial contains :



  1. Template hierarchy in details

  2. Practical Application

  3. Importance of WordPress Template Hierarchies



The post WordPress Template Hierarchy appeared first on Tutorial Mini.


Related posts:



  1. The Anatomy of a WordPress Theme – Theme Location

  2. WordPress SEO Tutorial – Template Optimization

  3. The Anatomy of a WordPress Theme






via Tutorial Mini http://tutorialmini.com/wordpress-template-hierarchy/

Sunday, August 26, 2012

The Anatomy of a WordPress Theme – Debug and Validate After Composing a Theme

WordPress Security

WordPress Security (Photo credit: Nikolay Bachiyski)



The final piece of the WordPress theme development puzzle comes in the form of debugging and validation. These two elements go hand in hand, as many themes will develop bugs because of coding errors, and those coding errors will cause online validators to simply display error messages; the W3C calls such themes “invalid” and urges all web designers to correct any errors to ensure the smooth operation of their theme in multiple browsers across all computing platforms.


The most important thing to test after a theme has been developed is whether or not the content is being pulled properly from the database, and whether it’s displaying properly on the page. If the content simply isn’t being pulled out of the database, it’s likely that either the opening WordPress Loop syntax was botched during the design process, or one or more of the WordPress PHP variables used for displaying content has been placed incorrectly into the file. Check for typos, spaces or errant punctuation in the PHP code, and other small mistakes which might affect the display of entries and page content.


When all of the appropriate testing has been completed, and when the theme is perfect in both content and appearance, developers can either keep their theme to themselves or upload the work to the WordPress Extend theme gallery for others to download and enjoy.


This is a part of The Anatomy of a WordPress Theme tutorial.



The post The Anatomy of a WordPress Theme – Debug and Validate After Composing a Theme appeared first on Tutorial Mini.


Related posts:



  1. The Anatomy of a WordPress Theme – Theme Files and Typical File Structure

  2. The Anatomy of a WordPress Theme – Theme Location

  3. The Anatomy of a WordPress Theme






via Tutorial Mini http://tutorialmini.com/the-anatomy-of-a-wordpress-theme-debug-and-validate-after-composing-a-theme/

The Anatomy of a WordPress Theme – Dynamic Content

Slippery eight loop

Slippery eight loop (Photo credit: Wikipedia)



Now that all of the standard template files have been created, and the header, footer, and sidebar can be dynamically included into any template file using standard WordPress PHP variables, it’s time to pull the actual WordPress content into the templates for display to the end user. This is done on almost every page by using a variation of the so-called “WordPress Loop.”


Without using database queries and advanced pieces of code, one WordPress Loop can be included per template file when displaying post content, the dynamic content assigned to pages from within the WordPress Dashboard, and creating single category, archive, and tag pages. The Loop is even used in the comment template to pull entries from the database, and a second “Comment Loop” is used to pull the associated interactions with that entry from a linked database table.


The WordPress Loop always starts with the code below, which simply checks the database to see if there are any entries to display based on the template hierarchy currently in action. That means the Loop will automatically look for certain categories, date ranges, or tags, based on the permalink a user has clicked. Here’s how that conditional looks:



<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

Next, template developers can begin calling information from the database and printing it on the page by using standard WordPress PHP variables. These can be used to display things like the entry title, the full content or an excerpt of the content, tags, categories, the date, the author’s name, and permalink information for inclusion in an <a>tag. Here’s a very basic example of a WordPress Loop pulling entry information using these variables:



&lt;a href="&lt;?php the_permalink() ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;br/&gt;
Posted on &lt;?php the_time('F D y') ?&gt;
&lt;p&gt;&lt;?php the_content(); ?&gt;&lt;/p&gt;

Now that the appropriate information has been pulled out of the database using these simple WordPress PHP variables, the WordPress Loop must be closed. This process involves not only bringing an end to the built-in database queries, but also using another conditional statement to print a brief error message to readers if no content is found for display within the Loop. This will happen if a user visits a category page for which no entries have been assigned, or if they navigate to an archive month during which no entries were posted. Here’s how the end of the Loop looks in most standard WordPress templates:



&lt;?php endwhile; ?&gt;
&lt;?php else : ?&gt;
&lt;?php _e("Unfortunately, there are no entries to be displayed here. Please try a different link."); ?&gt;

The php_e variable above is simply an instruction that an error message should be displayed to users who find an empty Loop on any of the site’s dynamic template pages. The text within the parentheses can be customized to a template developer’s liking, and the tag can be surrounded by standard XHTML elements in order to customize its display via CSS code in the style.css file which was created and discussed earlier in this primer on theme anatomy.


This is a part of The Anatomy of a WordPress Theme tutorial.



The post The Anatomy of a WordPress Theme – Dynamic Content appeared first on Tutorial Mini.


Related posts:



  1. The Anatomy of a WordPress Theme – Theme Files and Typical File Structure

  2. The Anatomy of a WordPress Theme – Theme Location

  3. The Anatomy of a WordPress Theme






via Tutorial Mini http://tutorialmini.com/the-anatomy-of-a-wordpress-theme-dynamic-content/

The Anatomy of a WordPress Theme – Theme Files and Typical File Structure

Files

Files (Photo credit: Velo Steve)



WordPress themes contain PHP template files, and those files must be named in a certain way in order for them to be seen and used by the software itself. While custom PHP template file can be created outside this mandatory file structure, it’s important to focus on creating these essential files first in order to ensure that every page within an installation can be properly displayed and used by the site’s readers.


Every theme must contain a style.css file; this file not only helps turn plain XHTML elements into vibrant containers for content, but also contains basic header information at the top of the file which identifies the theme’s name, author, version, homepage, and keywords. Without this file, and the header information it must include, the theme will not show up in the WordPress Dashboard and therefore will not be available for activation and use. For more information on what needs to be placed into this files, novice developers can visit the WordPress Codex for the series of lines and information they must customize to their theme.


The next files which should be created as part of the new theme should be the separate header and footer PHP template files. Almost every WordPress theme uses these files to split off the header and footer from the main content area, making it easy to alter those files and have the changes be reflected universally, rather than editing every content-containing file separately over a longer period of time. These files are pretty straightforward, but here’s a primer on each:



  • header.php should contain everything from the DOCTYPE tag to the end of the page’s navigation. This means that all <head> tag information, meta tags, <title> tag variables, and other information must be included in the site’s header. This template file also must contain the <?php wp_head(); ?> tag, which places valuable WordPress version-sharing information, and other website information, within the head of the document. It must be placed before the closing </head> tag.

  • footer.php begins when the page body closes, and includes any information that a user wishes to contain in the footer. This can be a content-rich footer, which is a currently-trendy way of closing the document, or simply a copyright statement and some valuable links to other resources. It must close the <body> tag as well as the HTML document itself, using the </html> tag before the end of the file.


Once these two files are created, they can be simply included into all of the other theme’s content-area PHP template files using WordPress PHP variables. It’s an exceedingly easy way to create a dynamic template, and users will be pleased with not having to learn extensive PHP inclusion coding in order to make the header and footer appear automatically on every page. With the header and footer complete, a new list of files must be created to display WordPress category, page, and post content to site readers. Those files include:



  • archive.php

  • category.php

  • index.php

  • page.php

  • search.php

  • single.php


With the theme’s content files created, there is one last required theme file and one more optional one which can be added to the containing folder. The required file (for the vast majority of WordPress installations) is the sidebar.php template. This file is pretty self-explanatory, and it contains the entire theme’s sidebar information. It can be included into all of the other content-specific template files by using a simple, WordPress-exclusive PHP variable. It simply gets placed within the sidebar <DIV> tag and that’s all there is to it.


With all of the actual content display template files created, there is one last thing which can be added to the theme’s containing folder. That is the functions.php file which serves not to display content, but rather to add functionality and alter how content is created, displayed, or interacted with. This file is sort of like a theme-specific listing of plugins; anything placed into functions.php will only modify the site’s operation while the relevant theme is selected. For most novice developers, this file is extraneous and will likely not need to be included with a theme. However, it’s a good idea to create a blank version of the file so that it can be easily added to at a later date, especially as theme development skills are joined by PHP coding skills which may prompt a user to add functions to the site.


This is a part of The Anatomy of a WordPress Theme tutorial.



The post The Anatomy of a WordPress Theme – Theme Files and Typical File Structure appeared first on Tutorial Mini.


Related posts:



  1. The Anatomy of a WordPress Theme – Theme Location

  2. The Anatomy of a WordPress Theme

  3. WordPress Basic – First Step With WordPress – Customizing Your WordPress Site






via Tutorial Mini http://tutorialmini.com/the-anatomy-of-a-wordpress-theme-theme-files-and-typical-file-structure/

The Anatomy of a WordPress Theme – Theme Location

English: WordPress Template Hierarchy. עברית: ...

English: WordPress Template Hierarchy. עברית: היררכית התבניות של וורדפרס. (Photo credit: Wikipedia)



For those truly novice WordPress theme developers, it’s time to learn where the software actually keeps all of its theme files and folders. Every WordPress installation is bundled with a wp-content directory; this directory is generally used to contain everything a user might upload to the installation on their own, including plugins, image or other media uploads, and the WordPress theme files themselves.


WordPress themes are not contained in singular files, but are instead bundled together within a folder of their own. This folder is placed within the themes subdirectory located in the wp-content folder on the server. Within this directory are several PHP template files which control the look and feel of the site’s header, footer, and content areas independently. A stylesheet is included to give these pages a user-friendly design, and optional files can be included to extend a theme’s functions or add JavaScript scripts to a theme itself.


Themes themselves are located within the following directory on the server, which can be accessed and modified using a simple FTP client:


/home/public_html/wp-content/themes/


Of course, if a WordPress installation is in a subfolder within public_html this server path would differ slightly. It’s easy to understand, however, where and how to access a theme’s folder and associated template files.


This is a part of The Anatomy of a WordPress Theme tutorial.



The post The Anatomy of a WordPress Theme – Theme Location appeared first on Tutorial Mini.


Related posts:



  1. The Anatomy of a WordPress Theme

  2. WordPress Basic – Installing WordPress – Famous 5-Minute Install

  3. WordPress Basic – Installing WordPress – Things to Know Before Installing WordPress






via Tutorial Mini http://tutorialmini.com/the-anatomy-of-a-wordpress-theme-theme-location/

The Anatomy of a WordPress Theme

WordPress

WordPress (Photo credit: Adriano Gasparri)



The great thing about WordPress is that, due to its surging base of 60 million users, it’s one of the most widely-developed and themed content management systems in the world. This isn’t just due to the popularity of the software itself, however; WordPress is actually exceedingly easy to theme and extend in various ways based on a user’s experience and needs.


The theme structure that has been used with the software for the better part of the past decade has always been rooted in combining XHTML, CSS, and PHP, and doing so in pretty basic, easy-to-understand ways. The best way to begin learning about these three technologies and how to integrate them into a new theme is to learn about the actual anatomy of a typical WordPress theme itself.


From storage to variables, file structure to features, all WordPress themes can be broken down and explained using basic terminology and compartmentalization.



  1. Theme Location

  2. Theme Files and Typical File Structure

  3. Dynamic Content

  4. Debug and Validate After Composing a Theme



The post The Anatomy of a WordPress Theme appeared first on Tutorial Mini.


Related posts:



  1. WordPress Basic – Features

  2. WordPress Basic – Installing WordPress

  3. WordPress Basic – First Step With WordPress – Customizing Your WordPress Site






via Tutorial Mini http://tutorialmini.com/the-anatomy-of-a-wordpress-theme/

WordPress Multisite Network With Multiple Domains – Prepare Your Network for Multiple Domain Handling

WordPress dashboard interface

WordPress dashboard interface (Photo credit: Wikipedia)



Once you’ve got WordPress Multisite setup, your next step is to install the WPMU DEV Multi Domains Plugin and the WPMU DEV Domain Mapping Plugin. These plugins will allow your users to map secondary installations of WordPress to their own domains. All they’ll need to do is point their DNS towards the IP address where your WordPress network is being hosted. More on that in a moment.


In order to set up and configure the domain mapping you’ll need to access the plugin options from your network admin dashboard. If you try to access them from the dashboard of the main site or a secondary site, you won’t be able to set it up.


So go to the “Network admin” option in your WordPress dashboard and look under “Settings” for the “domain mapping” option.


Unfortunately, the instructions on this screen are confusing and inaccurate, and you’ll drive yourself crazy trying to follow them to set up your domain mapping plugin. So let’s lay out exactly what you need to do to finish your installation up.


The first step reads like this:



  • Please copy the sunrise.php to /home/coach/public_html/wp-content/sunrise.php and uncomment the SUNRISE setting in the /home/coach/public_html/wp-config.php file.

    The “sunrise.php” isn’t actually under your root folder as it says in these instructions. It’s under the folder for the “domain-mapping” plugin which you’ll find under “wp-content” directory which is in the root directory where your WordPress installation.

  • Copy and paste ALL the code from the “sunrise.php” into your “wp-config.php” file, underneath all the existing code in the “wp-config.php” file. Next, remove the “<?php” which is at the top of the “sunrise.php file” before saving your “wp-config.php” file.

  • I also suggest creating a comment line just above the start of the code you just pasted from the “sunrise.php” file just to be clear on where your pre-existing “wp-config.php” code ends and the “sunrise.php” code starts.

    Here’s an example of such a comment line:

    */BEGIN SUNRISE PHP FILE CONTENTS


The next step in your WordPress admin dashboard should read like this:



  • Please uncomment the line //define( ‘SUNRISE’, ‘on’ ); in the /home/coach/public_html/wp-config.php file.

    Again, this is a potentially confusing line of code because I’ve yet to see the “//define( ‘SUNRISE’, ‘on’ );” in a “wp-config.php” file. So you’ll need to copy and paste the “define( ‘SUNRISE’, ‘on’ );” without the “//” characters in front of it or the quotations around it. Then, paste this just below the multisite rules which you’ve already pasted into your “wp-config.php” file.


Next, you’ll need to obtain your IP address where your website is hosted from your hosting provider and input that into the place where it requests your IP. DO NOT use YOUR IP for this. It needs to be the IP where your website is hosted, not the IP you log on to the internet with.


The fourth setup option asks if you want non-supporters to be able to set up sites on your network, I’ll leave that up to you.


Finally, you can choose which domain the visitors will be mapped to. I use “domain entered by user” for this option, but again that’s up to you.


Now, your users will be able to set up sites on your network and (provided that their DNS is pointed towards the IP address where your WordPress network is hosted), their sites will map to their own domain.


This is a part of WordPress Multisite Network With Multiple Domains tutorial.



The post WordPress Multisite Network With Multiple Domains – Prepare Your Network for Multiple Domain Handling appeared first on Tutorial Mini.


Related posts:



  1. WordPress Multisite Network With Multiple Domains – Prepare WordPress for Multisite

  2. WordPress Multisite Network With Multiple Domains

  3. WordPress Basic – Installing WordPress – Famous 5-Minute Install






via Tutorial Mini http://tutorialmini.com/wordpress-multisite-network-with-multiple-domains-prepare-your-network-for-multiple-domain-handling/