Keep these following tags in your pocket and learn them by heart , soon you will be on your way to worpress !
Theme Structure If we want to create a WordPress theme, these following files must be included in order to be a standard theme. we can create a theme using fewer files but this is the way to do it. header.php – header section index.php – main section sidebar.php – sidebar section footer.php – footer section single.php – post template page.php – page template comments.php – comments template search.php – search content searchform.php – search form archive.php – archive functions.php – special functions 404.php – error page Template Include Tags These tags are usually used in a single PHP file to include other files from the theme. For example we can use the get_header tag in index.php in order to include the head in the theme. < ?php get_header(); ?> < ?php get_sidebar(); ?> < ?php get_footer(); ?> < ?php comments_template(); ?> The Loop we will often see “the loop” as reference in many tutorials or samples. This piece of code helps we display wer posts on a blog. By entering custom HTML or PHP code inside the loop, we will make every post to benefit from that custom code. we can use the loop mainly in wer index.php file but also in other files when we want to display multiple posts. < ?php if(have_posts()) : ?> < ?php while(have_posts()) : the_post(); ?> // Custom HTML & PHP code < ?php endwhile; ?> < ?php else : ?> < ?php endif; ?> WordPress Conditional Tags Conditional tags are simple but helpful tags that can be used to customize how wer blog will work. For example if the page is the home page, we will type a class called “current-cat”. < ?php if(is_home()) { ?> class=”current-cat”< ?php } ?>. This is a part of the code which I will present we a little bit later in this article. is_page() – when a page is displayed is_category() – when a category is displayed is_home() – when the user is on the home page(blog) is_front_page() – when the user is on the home page (blog or page) is_single – when a single post is displayed is_sticky() – check if a post is sticky WordPress Navigation Menu This thing is different based on how we want wer blog to work. we can have a menu based on pages, on categories or on both. In every way we will need a home page link. In this case here the the 2 approaches for the menu. <ul id=”menu”> <li <?php if(is_home()) { ?> class=”current-cat”< ?php } ?>> <a href=”<?php bloginfo(‘home’); ?>”>Home</a></li> < ?php wp_list_categories(‘title_li=&orderby=id’); ?> </ul> Pages based menu <ul id=”menu”> <li <?php if(is_home()) { ?> class=”current_page_item”< ?php } ?>> <a href=”<?php bloginfo(‘home’); ?>”>home</a></li> < ?php wp_list_pages(‘sort_column=menu_order&depth=1&title_li=’); ?> </ul> Display N posts from a category On the first page we have in the sidebar 2 sections for latest tips and latest graphic ratings. Those sections were made with the help of the query_posts. < ?php query_posts(‘category_name=Name Here&showposts=10’); ?> Custom Template File In WordPress we can insert any additional template file that is none of the ones in the first section. In this way we can make wer own template file and embed it in wer theme. < ?php include (TEMPLATEPATH . ‘/searchform.php’); ?> Template Bloginfo Tags These tags are used to display information regarding wer blog, information that can be customized inside the WordPress Administration panel. < ?php bloginfo(‘template_url’); ?> – Displays the URL of the template < ?php bloginfo(‘pingback_url’); ?> – Displays the pingback URL < ?php bloginfo(‘stylesheet_url’); ?> – Displays the URL for the template’s CSS file < ?php bloginfo(‘wpurl’); ?> – Displays URL for WordPress installation < ?php bloginfo(‘name’); ?> < ?php bloginfo(‘name’); ?> – Title of the blog < ?php bloginfo(‘charset’); ?> – Displays the character set < ?php bloginfo(‘description’); ?> – Displays the description of the blog < ?php bloginfo(‘url’); ?> – Displays the address of the blog < ?php bloginfo(‘rss2_url’); ?> – Displays the RSS URL < ?php wp_list_cats(); ?> – Displays the categories < ?php get_calendar(); ?> – Displays the calendar Common WordPress Tags : As we know WordPress has a lot of code that can be embedded in themes in order to make them complex and powerful. Here are some of the common snippets that are used in most of the templates. < ?php wp_get_archives() ?> – Displays a date-based archives list < ?php posts_nav_link(); ?> – Displays Previous page and Next Page links < ?php next_post_link() ?> – Displays Newer Posts link < ?php previous_post_link() ?> – Displays previous link < ?php the_time() ?> – Displays the time of the current post < ?php the_date() ?> – Displays the date of a post or set of posts < ?php the_title(); ?> – Displays or returns the title of the current post < ?php the_permalink() ?> – Displays the URL for the permalink < ?php the_category() ?> – Displays the category of a post < ?php the_author(); ?> – Displays the author of the post < ?php the_ID(); ?> – Displays the numeric ID of the current post < ?php wp_list_pages(); ?> – Displays all the pages < ?php wp_tag_cloud(); ?> – Displays a tag cloud