This post will go over the functions that I tend to use quite often when designing WordPress themes. As I find out and use more I will update this page as needed.
List of the main Functions for all parts of a WordPress page:
<?php get_header(); ?> <?php have_posts(); ?> <?php the_content(); ?> <?php get_sidebar(); ?> <?php get_footer(); ?>
URL for default style sheet in WordPress which is located: (http://server/wp-content/themes/theme_name/style.css )
<?php bloginfo('stylesheet_url'); ?>
The name of the website name:
<?php bloginfo('name'); ?>
The root of the theme directory. ( http://server/wp-content/themes/theme_name/ )
<?php bloginfo('template_url')?>
Root of the wordpress site:
<?php echo get_option('home'); ?>
The title of the page/post:
<?php the_title(); ?>
Next/Previous Post Link functions:
<?php nex_posts_link('Older Entries') ?> <?php previous_posts_link('Newer Entries') ?>
The content of the page/post:
<?php the_content('<p class="serif">Read the rest of this page »</p>'); ?>
Display the category decription:
<?php echo category_description( $category ); ?>
The time at which the page/post was posted
<?php the_time('l, F jS, Y') ?>
Display the pages of the WordPress website. You can also include or exclude certain pages:
<?php wp_list_pages(); ?> <?php wp_list_pages("title_li=&include=2,3,22,41"); ?> <?php wp_list_pages("title_li=&exclude=2,3,22,41"); ?>*NOTE* to find out what the page number is log into WordPress admin section and go to the “Pages” section. If you hover over the “Page Title” at the bottom of the webpage in the status bar you can tell what the page number is ( If anyone knows how to do this any better please let me know ) :
How to limit the number of posts in “the loop”. In this example I chose I wanted to only show 4 posts per page. I went even further by telling the “Query_posts” to only look for category 17 which on my website is my recipe category. This line MUST be inserted BEFORE “the loop”.
<?php query_posts("cat=17&showposts=4") ?>Eternal Info
*NOTE* If you can’t find what you need here you can always check out check out the Official WordPress Function Reference page.
Leave a Reply