Showing posts with label Wordpress Functions. Show all posts
Showing posts with label Wordpress Functions. Show all posts

LearnPress Plugin How to Add Currency ThimPress in Wordpress

LearnPress Plugin How to Add New Currency ThimPress in Wordpress


Hi Today I discussed LearnPress Plugin How to Add New Currency ThimPress in Wordpress. Wordpress woo-commerce LearnPress Plugin Add New Currency and Symbol Here Code.

LearnPress Plugin How to Add Currency ThimPress in Wordpress
LearnPress Plugin How to Add Currency ThimPress in Wordpress
 
Theme functions.php file Edit Paste this Code


Add currecies edit your own currency and then save and check it.

add_filter( 'learn_press_get_payment_currencies', 'add_my_currency' );

function add_my_currency( $currencies ) {

     $currencies['PKR'] = 'Pakistan';

     return $currencies;

}

add_filter('learn_press_currency_symbol', 'add_my_currency_symbol', 10, 2);

function add_my_currency_symbol( $currency_symbol, $currency ) {

     switch( $currency ) {

         case 'PKR': $currency_symbol = 'Rs.'; break;

     }

     return $currency_symbol;

}

How to Create New Modules Wordpress without plugin

How to Create New Modules Wordpress without plugin

 Hi, Today Discussed WordPress Theme customized and admin and frontend How to Create new modules Wordpress without plugin created this task discussed today.  New modules without plugin Follows Briefly discussed.

How to Create New Modules Wordpress without plugin
How to Create New Modules Wordpress without plugin
public_html/wp-content/themes/themesname/admin

Create Staff.php

<?php

//
// 'staff' Custom Post Type
//

// Register the Post Type - staff
// http://codex.wordpress.org/Function_Reference/register_post_type
add_action('init', 'register_staff');

function register_staff() {
 
 $labels = array(
  'name' => _x('Staff', 'post type general name'),
  'singular_name' => _x('Staff', 'post type singular name'),
  'add_new' => _x('Add New', 'Staff'),
  'add_new_item' => __('Add New Staff Member'),
  'edit_item' => __('Edit Staff'),
  'new_item' => __('New Staff'),
  'view_item' => __('View Staff'),
  'search_items' => __('Search Staffs'),
  'not_found' =>  __('Nothing found'),
  'not_found_in_trash' => __('Nothing found in Trash'),
  'parent_item_colon' => ''
 );
 
 $args = array(
  'labels' => $labels,
  'public' => true,
  'publicly_queryable' => true,
  'show_ui' => true,
  'query_var' => true,
  'rewrite' => array(
            'slug' => 'staff',
            'with_front' => false
            ),
  'has_archive' => 'staff',
  'capability_type' => 'page',
  'hierarchical' => false,
  'menu_position' => 22,
  'supports' => array('custom-fields') // 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions' , 'page-attributes' 
 ); 
 
 register_post_type( 'staff' , $args );
}

//
// Create Profile Images sizes
if ( function_exists( 'add_image_size' ) ) {
 add_image_size( 'staff-profile-small', 45, 45, true ); 
 add_image_size( 'staff-profile-thumb', 124, 124, true );
 add_image_size( 'staff-profile', 204, 204, true );
}

//
// Add Meta Boxes
// http://codex.wordpress.org/Function_Reference/add_meta_box
//

function tpx_staff_init(){
 add_meta_box("metabox_staff_staff", "Staff Details", "metabox_staff_staff", "staff", "normal","high");
 add_meta_box("metabox_staff_description", "Description", "metabox_staff_description", "staff", "normal","high");
 
}
add_action("admin_init", "tpx_staff_init");

function metabox_staff_staff() {
 global $post;
 ?> 
    <div class="custom_meta">
     <div class="photo_profile">
            <label>Photo</label>
         <div class="fileWrapper"><?php
   $photo_profileID = get_post_meta($post->ID, 'staff_file_photo_profile', true);
   $photoArray = wp_get_attachment_image_src( $photo_profileID, 'staff-profile-thumb', false);
   $photoSrc = $photoArray[0];
   if($photoSrc){
    echo '<a class="photo"><img src="' . $photoSrc . '" alt="staffimage" /></a>';
   } else {
    echo '<a class="photo"><span>Upload Photo</span></a>';
   }
   ?>
            <input type="file" name="staff_file_photo_profile" /></div>
        </div>
     <ul class="formfields">
         <li>
            <label>First Name</label>
            <?php tpx_meta_input_text('staff_name_first'); ?>
            </li>
         <li>
            <label>Surname</label>
            <?php tpx_meta_input_text('staff_name_last'); ?>
            </li>
         <li>
            <label>Position</label>
            <?php tpx_meta_input_text('staff_position'); ?>
            </li>
        </ul>
    </div>
 <?php 
}
function metabox_staff_description() {
 global $post;
 ?>
    <div class="custom_meta">
     <?php 
     $staff_description = get_post_meta($post->ID, 'staff_description', true);
  the_editor($staff_description, 'staff_description', 'title', false, 1); ?>
    </div>
<?php
}
add_action('save_post', 'save_staff_meta');

function save_staff_meta(){
 global $post, $initLoop;
 $prefix = "staff_";
 $initLoop = true;
 
 //Upload Headshot
 foreach($_FILES as $field => $file){
  if($field == 'staff_file_photo_profile'){
   $filename = $_POST['staff_name_first'] . ' ' . $_POST['staff_name_last'] . ' Profile Photo';
   tpx_save_attachement($file, $post->ID, $filename, 'staff_file_photo_profile');
   //Remove it from the array to avoid duplicates.
   unset($_FILES[$field]);
  }
 }
 
 //Normal Inputs
 foreach($_POST as $field => $value){
  $has_prefix = strstr($field, $prefix);
    
  if($has_prefix){
   //Capitalize Name
   if($field == 'staff_name_first') $value = ucwords($value);
   if($field == 'staff_name_last') $value = ucwords($value);
   
   if($value){
    update_post_meta($post->ID, $field, $value); // Save Value
   } else {
    delete_post_meta($post->ID, $field); // Remove it if its not there
   }
  } 
 }
}

add_filter('wp_insert_post_data', 'update_staff_title', 10, 2);

function update_staff_title($data, $postarr){
 if($data['post_type'] == 'staff' && $_POST['staff_name_first']){
  $new_title = $_POST['staff_name_first'] . ' ' . $_POST['staff_name_last'];
  $new_slug = strtolower($_POST['staff_name_first']) . '-' . strtolower($_POST['staff_name_last']);
  $new_slug = str_replace(' ', '', $new_slug);
  $data['post_title'] = ucwords($new_title);
  $data['post_name'] = $new_slug;
 }
 return $data;
}


//
// Sort Staff Menu
//

// add the admin options page
add_action('admin_menu', 'tpx_add_page_sort_staff');
function tpx_add_page_sort_staff() {
 add_submenu_page('edit.php?post_type=staff', 'Sort Staff', 'Sort Staff', 'edit_pages', 'tpx-staff-sort', 'tpx_options_staff_sort');
 add_submenu_page('edit.php?post_type=staff', 'Staff Overview', 'Overview', 'edit_pages', 'tpx-staff-overview', 'tpx_options_staff_overview');
}

//
// Sort Staff Page
//
function tpx_options_staff_sort() {
 $tpx_options_staff_sort = get_option( 'tpx_options_staff_sort');
?>
    <div class="wrap">
    <h2>Sort Staff</h2>
    <p>Click and Drag to sort the order of staff members</p>
    <div id="poststuff" class="tpx_options">
    <form action="options.php" method="post">
    <?php settings_fields('tpx_options_staff_sort'); ?>
    <ul class="tpx_sort_list">
     <?php
  $args = array(
   'post_type' => 'staff',
   'orderby' => 'menu_order',
   'order' => 'ASC',
   'posts_per_page' => -1
  );
  $staff_list = get_posts($args);
  foreach($staff_list as $staff){
   echo '<li class="draggable" id="' . $staff->ID . '">'. $staff->post_title . '<li>';
  }
  ?>
    </ul>
    <input name="tpx_options_staff_sort[staff_order]" type="hidden" value="" class="sort_value" />
    <input name="Submit" type="submit" value="<?php esc_attr_e('Publish'); ?>" class="button-primary" />
    </form></div></div>
<?php
}


//
// Staff Overview Page
//

function tpx_options_staff_overview() {
 $tpx_options_staff_overview = get_option( 'tpx_options_staff_overview');
?>
    <div class="wrap">
    <h2>Staff Overview</h2>
    <p>This text will appear on the front page of the website.</p>
    <div id="poststuff" class="tpx_options tpx_options_staff_overview">
    <form action="options.php" method="post" enctype="multipart/form-data" encoding="multipart/form-data"  accept-charset="utf-8">
    <?php settings_fields('tpx_options_staff_overview'); ?>
    <div class="feature_image ">
        <h3>Feature Image</h3>
        <?php 
        $attachment_ID = $tpx_options_staff_overview['feature_id'];
        tpx_attachment_uploader($attachment_ID, 'feature_attachment', 'photo-medium') 
  ?>
    </div>
    <div class="tiny_mce_wrapper"><?php the_editor($tpx_options_staff_overview['html'], 'tpx_options_staff_overview[html]', 'title', false, 1); ?></div>
    <input name="Submit" type="submit" value="<?php esc_attr_e('Publish'); ?>" class="button-primary" />
    </form></div></div>
<?php
}


// add the admin settings and such
add_action('admin_init', 'tpx_staff_admin_init');

function tpx_staff_admin_init(){
 register_setting( 'tpx_options_staff_sort', 'tpx_options_staff_sort', 'tpx_options_staff_sort_validate' );
 register_setting( 'tpx_options_staff_overview', 'tpx_options_staff_overview', 'tpx_options_staff_overview_validate' );
 add_settings_section('tpx_staff_main', 'Main Settings', 'tpx_staff_section_text', 'tpx_staff_section');
 add_filter( 'option_page_capability_tpx_options_staff_sort', 'tpx_options_staff_sort_capability' );
}
function tpx_options_staff_sort_capability( $capability ) {
 return 'edit_pages';
}

// validate our options
function tpx_options_staff_sort_validate($input) {
 $list_string = $input['staff_order'];
 if($list_string){
  $IDs = explode(',', $list_string);
  $count = 0;
  //print_r($staff_IDs);
  foreach($IDs as $ID){
   if($ID != ''){
    $staff_post = array();
    $staff_post['ID'] = $ID;
    $staff_post['menu_order'] = $count;
    wp_update_post($staff_post);
    $count++;
   } else {
    unset($ID);
   }
  }
  $newinput['staff_order'] = implode(',', $IDs);
 }
 return $newinput;
}

// validate our options
function tpx_options_staff_overview_validate($input) {
 $attachment_id = tpx_save_attachement($_FILES['feature_attachment'], 0, 0, 0, true);
 if($_POST['remove_feature_attachment']) $newinput['feature_id'] = '';
 //echo '$attachment_id - ' . $attachment_id;
 if($attachment_id) $newinput['feature_id'] = $attachment_id;
 $newinput['html'] = $input['html'];
 return $newinput;
}
?>
Create Function.php

Include('staff.php');
function menu_order_filter($menu) {
 $dev_menu = array(
   
  'edit.php?post_type=staff',  
  
  );
 array_splice($menu, 1, 0, $dev_menu);
 return array_unique($menu);
}

add_filter('custom_menu_order', create_function('', 'return true;'));
add_filter('menu_order', 'menu_order_filter');
Frontend
public_html/wp-content/themes/themename

Create sidebar-staff-profiles.php


<div class="staff_profiles">
<ul class="staff">
<?php
$args = array(
 'post_type' => 'staff',
 'posts_per_page' => -1,
 'orderby' => 'menu_order',
 'order' => 'ASC'
);
$staffs = get_posts($args);
foreach($staffs as $staff){
 $profile_id = get_post_meta($staff->ID, 'staff_file_photo_profile', true);
 $profile_img = tpx_attachment_src($profile_id, 'staff-profile-thumb');
 $fname = get_post_meta($staff->ID, 'staff_name_first', true);
 $lname = get_post_meta($staff->ID, 'staff_name_last', true);
 setup_postdata($staff);
?>
 <li>
     <?php
  if($profile_img){ 
  ?>
        <div class="row">

     <div class="small-12 large-4 columns headshot">
         <a href="<?php echo get_permalink($staff->ID) ?>">
<img src="<?php echo $profile_img ?>" alt="vinoth" class="photo"/>
</a><!---->
        </div>
        <?php } ?>
        <div class="small-12 large-8 columns details">
            <h4 class="name">
                <?php
                echo $fname . ' ' . $lname
                ?>
            </h4>
            <div class="excerpt">
                <?php
                $excerpt = substr(get_post_meta($staff->ID, 'staff_description', true), 0, 180) . '...';
                echo wpautop($excerpt);
                ?>
            </div>
            <div class="readmore"><a href="<?php echo get_permalink($staff->ID) ?>" class="button small">View <?php echo $fname ?>'s Profile</a></div>
        </div>
        </div>
    </li>
 
<?php  } ?>
</ul>
</div>
Create Single-staff.php

<?php get_header(); ?>
<section class="feature fixed bg-1">
 <div class="row">
        <div class="small-12 columns">
    <?php 
    $current_post_type = get_post_type_object(get_post_type($post->ID));
    ?>
         <ul class="breadcrumb">
       <li><a href="<?php echo get_permalink(6) ?>">About Us</a></li>
                <li><?php echo $post->post_title ?></li>
            </ul>
        </div>
    </div>
</section>
<section class="main">
    <div class="row">
     <?php 
  $profile_id = get_post_meta($post->ID, 'staff_file_photo_profile', true);
  $profile_img = tpx_attachment_src($profile_id, 'staff-profile');
  if($profile_img){
  ?>
     <div class="small-12 medium-4 large-3 columns mrg-1">
            <div class="headshot">
         <?php
   echo '<img src="' . $profile_img . '" alt="singlestaffphotos" class="photo" />';
   ?>
            </div>
        </div>
        <?php } // endif ?>
        <div class="small-12 medium-8 large-9 columns">
            <div class="page content">
                <?php if (have_posts()) : ?>
                    <?php while (have_posts()) : the_post(); ?>    
                        <article class="tiny_mce">
                        <?php echo wpautop(get_post_meta($post->ID, 'staff_description', true)) ?>
                        </article>
                    <?php endwhile; ?>
                <?php endif; ?>
                <div class="options"><a href="<?php echo get_permalink(6) ?>" class="button back">All Staff</a></div>
            </div>
        </div>
    </div>
</section>
<?php get_footer(); ?>

Wordpress Dropdown Category Ajax Search

WordPress Drop down Category Ajax Search


Today Discussed wordpress dropdown category list ajax search without plugin and create shortcodes follows briefly discussed. normally any search field or any one task mostly used plugin activate list of more then plugin this the wordpress large file and buy the plugin. So just avoid plugin hardcode this wordpress is category list ajax search follows code.

Wordpress Dropdown Category Ajax Search
Wordpress Dropdown Category Ajax Search


shortcodes.php

function ajax_filter_search($atts, $content = null) {
    extract(shortcode_atts(array(
  'post_type'    => AFSAdmin::afs_retrieve('_general_post_type'),
  'post_tax'     => AFSAdmin::afs_retrieve('_general_post_taxonomy'),
  'posts_per_page'  => AFSAdmin::afs_retrieve('_general_posts_per_page'),
  'filter_type'   => '',
  'filter_by'     => '',
  'filter_months'    => '',
  'filter_years'    => '',
  'filter_withPDF'   => '',
  'offset'     => 0,
    ), $atts));

ajax filter search what ever search stored array format year month and pdf taxnonmy etc.,  and included functions and follows code.

if($post_type == '') { } else { $afs_args .=' post_type="'.$post_type.'" '; }
 if($posts_per_page == '') { } else { $afs_args .=' posts_per_page="'.$posts_per_page.'" '; }
 if($filter_by == '') { } else { $afs_args .=' filter_by="'.$filter_by.'" '; }
 if($filter_months == '') { } else { $afs_args .=' filter_months="'.$filter_months.'" '; }
 if($filter_years == '') { } else { $afs_args .=' filter_years="'.$filter_years.'" '; }
 if($filter_withPDF == '') { } else { $afs_args .=' filter_withPDF="'.$filter_withPDF.'" '; }
 if($offset == '') { } else { $afs_args .=' offset="'.$offset.'" '; }
  
 if($filter_type == '') { 
  $all='all'; 
  $filter_type_count = 999;
 } else { 
  $afs_args .=' filter_type="'.$filter_type.'" '; 
  $all=$filter_type;
  $filter_type_array = explode(',',$filter_type);
  $filter_type_count = count($filter_type_array);
 }
  
 $text = '';
 $i = 1;
ajax filter conditions check else and true or false conditions check and then show this html code included same php format follows.

$text .= '<div id="afs-wrapper">';
 $text .= ' <div class="press-releases">';
 $text .= '  <form id="newsForm">';
 $text .= '   <div class="row">';
 
 
 $text .= '    <div class="col-xs-1TableRowItem2">';
 
   $text .= '       <label for="category"><strong>Display:&nbsp;</strong></label>';
   $text .= '       <select name="category">';
   $text .= '        <option value="all">All</option>';
             $terms = get_terms($taxonomy, $args = array('orderby'=>'id') );
             if($terms) {
             
              foreach($terms as $term) {
               if(isset($filter_type_array)) {
                if(in_array($term->slug,$filter_type_array)) {
                 if($term->name == 'Uncategorized') { continue; }
                 $text .= '<option value="'.$term->slug.'">'.$term->name.'</option>';
                }
               } else {
                if($term->name == 'Uncategorized') { continue; }
                 $text .= '<option value="'.$term->slug.'">'.$term->name.'</option>';
               }
              }
             }
   $text .= '       </select>';
   $text .= '      </div>';
   $text .= '     </div>';
  }
  } 
 
function.php

if (!function_exists('myplugin_ajaxurl')) {
 add_action('wp_head', 'myplugin_ajaxurl');
 
 function myplugin_ajaxurl() {
 
    echo '<script type="text/javascript">
      var ajaxurl = "' . admin_url('admin-ajax.php') . '";
      var scriptpath = "' . site_url() . '";
    </script>';
 }
}

if (!function_exists('my_action_callback')) {
 // Ajax call to sort PRs
 function my_action_callback() {  
 
  // Get the values:
  $post_type  = AFSAdmin::afs_retrieve('_general_post_type');
  $posts_per_page = AFSAdmin::afs_retrieve('_general_posts_per_page');
  $filter_type  = $_POST['filingType'];
  $filter_by   = $_POST['filterBy'];
  $filter_months  = $_POST['filterMonths'];
  $filter_years  = $_POST['filterYears'];
  $filter_withPDF = $_POST['withPDF'];
 
  $offset    = $_POST['page'];
  
  echo do_shortcode('[afs_feed post_type="'.$post_type.'" posts_per_page="'.$posts_per_page.'" offset="'.$offset.'" filter_type="'.$filter_type.'" filter_by="'.$filter_by.'" filter_months="'.$filter_months.'" filter_years="'.$filter_years.'" filter_withPDF="'.$filter_withPDF.'"]');
 
  exit;
 
 }
 
 add_action('wp_ajax_my_action', 'my_action_callback');
 add_action('wp_ajax_nopriv_my_action', 'my_action_callback');
}

/*******************************************************************
* AJAX IN ADMIN
********************************************************************/
if (!function_exists('get_selected_taxonomy')) {
 // Ajax call to get taxnomy values
 function get_selected_taxonomy() {  
 
  // Get the values:
  $cur_post_tax = AFSAdmin::afs_retrieve('_general_post_taxonomy');
  $post_type   = $_POST['option'];
  
  $taxonomy_objects = get_object_taxonomies($post_type, 'objects');
  
  if($taxonomy_objects) {
   foreach($taxonomy_objects as $tax) {
    $sel = '';
    if($tax->name == 'post_format') {
     continue;
    } else {
     if($tax->name == $cur_post_tax) { $sel = 'selected="selected"'; }
     echo '<option value="'.$tax->name.'" '.$sel.'>'.$tax->label.'</option>';
    }
   } 
  } else {
   echo '<option value="none" '.$sel.'>None</option>';
  }
 
  exit;
 
 }
 
 add_action('wp_ajax_get_selected', 'get_selected_taxonomy');
 add_action('wp_ajax_nopriv_get_selected', 'get_selected_taxonomy');
}

/*add_action( 'admin_footer', 'my_action_javascript' ); // Write our JS below here

function my_action_javascript() { ?>
 <script type="text/javascript" >
 jQuery(document).ready(function($) {
  
  $('#afs-form input#submit').on({
   click: function(){
    
    //return false;
    
   }
  });
  
  var data = {
   'action': 'my_action',
   'whatever': 1234
  };

  // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
  jQuery.post(ajaxurl, data, function(response) {
   console.log('Got this from the server: ' + response);
  });
 });
 </script> <?php
}*/
?>

How to related Post show in wordpress

How to related Post show in wordpress

How to related Post show in wordpress
How to related Post show in wordpress

How to related post show in wordpress is today discussed. Blog posting and any other post related post showing index page or any other page showing wordpress themes folder wp-contents and new folder create includes and showing code follows.

/public_html/wp-content/themes/themsname/includes/post-formats/related-posts.php

<?php
$tags = wp_get_post_tags($post->ID);
if ($tags) {
$tag_ids = array();

foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
$args=array(
'tag__in' => $tag_ids,
'post__not_in' => array($post->ID),
'showposts' => 4, // these are the number of related posts we want to display
'caller_get_posts'=>1,
'ignore_sticky_posts' => 1 // to exclude the sticky post
);
// WP_Query takes the same arguments as query_posts
$related_query = new WP_Query($args);
if ($related_query->have_posts()) {
?>

<?php $blog_related = of_get_option('blog_related'); ?>
<?php if($blog_related){?>
<h3><?php echo of_get_option('blog_related'); ?></h3>
<?php } else { ?>
<h3><?php _e('Related Posts','drivingSchool');?></h3>
<?php } ?>
<ul class="related-posts">
<?php
while ($related_query->have_posts()) : $related_query->the_post();
?>
<li>
<?php if(has_post_thumbnail()) { ?>
<?php
$thumb = get_post_thumbnail_id();
$img_url = wp_get_attachment_url( $thumb,'full'); //get img URL
$image = aq_resize( $img_url, 140, 100, true ); //resize & crop img
?>
<figure class="featured-thumbnail">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img src="<?php echo $image ?>" alt="<?php the_title(); ?>" /></a>
</figure>
<?php } ?>

<h6 class="relatedPost"><a href="<?php the_permalink() ?>" > <?php the_title();?> </a></h6>
</li>
<?php
endwhile;
?>
</ul>
<?php }
wp_reset_query();
}
?>
Single.php

Which page showing related  post just copy and past this code. and more wordpress functions click here

<?php get_template_part( 'includes/post-formats/related-posts' ); ?>
<?php comments_template('', true); ?>


All in one SEO Wordpress

All in one SEO Wordpress

All in one SEO is Wordpress Most using Search Engine Optimized Plugin. This Plugin Compare SEO Yoast is Most used and user friendly easily optimized Plugin in All in One SEO Plugin. This Plugin More then keyword put this single page and easily write meta keyword and meta description and meta title. Most Top 5 Plugin in Wordpress
All in one SEO Wordpress
All in one SEO Wordpress

Features:
  1. Support for SEO on custom post types
  2. Google Analytics support.
  3. Fine tune page Navigational links
  4. XML sitemap.
  5. Automatically generate meta tag.
  6. Translate 48 Language.
  7. Built-in API so other plugins/themes can access and extend functionality
XML Sitemap
XML Sitemap
All in One Seo XML sitemap Generate follow and index no index settings this image. default generated xml sitemap and custom link settings page in this plugin.

display settings
display settings

All in One SEO display settings page post and media and locations show column lables customized field easily this plugin.
Menu
Menu

All in One SEO Plugin is perfect Search Engine Optimized Plugin this Plugin Download Click Here

Categorized list of WordPress functions

Categorized list of WordPress functions that are commonly used when building, updating and maintaining templates.

Wordpress Basics Temlate Files and updates customized data and categorized listed and funcation loop functions and basics function and default functions follows.

Categorized list of WordPress functions
Categorized list of WordPress functions


Basic Template Files

File Name Description
style.css style sheet file
index.php   ome page file
header.php header content file
single.php single post page file
archive.php archive/category file
searchform.php search form file
search.php search content file
404.php error page file
comments.php  comments template file
footer.php footer content file
sidebar.php sidebar content file
page.php single page file
front-page.php latest posts or static page
tag.php display tags in archive format
category.php display categories in archive format


Header Functions

Function Description

<?php site_url(); ?>   root url for website

<?php wp_title(); ?> title of specific  post/page

<?php bloginfo('name'); ?> title of site

<?php bloginfo('description'); ?> site description

<?php get_stylesheet_directory(); ?> stylesheet folder location

<?php bloginfo('stylesheet_url'); ?> style.css file location

<?php bloginfo('pingback_url'); ?>  pingback url

<?php bloginfo('template_url'); ?> template folder path

<?php bloginfo('version'); ?> wordpress blog version

<?php bloginfo('atom_url'); ?> atom url

<?php bloginfo('rss2_url'); ?>  rss2 url

<?php bloginfo('url'); ?> root url for website

<?php bloginfo('html_type'); ?> html version

<?php bloginfo('charset'); ?> charset parameter

Navigation Menu

Default Navigation Menu

<?php wp_nav_menu(); ?>

Specific Navigation Menu

<?php wp_nav_menu( array('menu' => 'Project Nav' )); ?>

Category Based Navigation

<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>

Page Based Navigation

<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>

The Loop

Basic Loop

<?php if(have_posts()) { ?>

<?php while(have_posts()) { ?>

<?php the_post(); ?>

<?php // custom post content code for title, excerpt and featured image ?>

<?php } // end while ?>

<?php } // end if ?>

Template Functions

Function Description

<?php the_content(); ?> content of posts/pages

<?php if(have_posts()): ?> check if there are posts

<?php while(have_posts()): the_post(); ?> shows posts

<?php endwhile; ?> closes loop

<?php endif; ?> closes if

<?php get_header(); ?> header.php file contents

<?php get_sidebar(); ?> sidebar.php file contents

<?php get_footer(); ?> footer.php file contents

<?php the_time('m-d-y'); ?> the date is '08-18-07'

<?php comments_popup_link(); ?> link to comments of post

<?php the_title(); ?> title of post/page

<?php the_permalink(); ?> url of post/page

<?php the_category(); ?> category of post/page

<?php the_author(); ?> author of post/page

<?php the_ID(); ?> id of post/page

<?php edit_post_link(); ?> edit link of post/page

<?php wp_list_bookmarks(); ?> links from blogroll

<?php comments_template(); ?> comment.php file contents

<?php wp_list_pages(); ?> list all pages

<?php wp_list_categories(); ?> list all categories

<?php next_post_link('%link'); ?> url to next post

<?php previous_post_list('%link'); ?> url to previous post

<?php get_calendar(); ?> show post calendar

<?php wp_get_archives(); ?> list of archive urls

<?php posts_nav_link(); ?> next and previous post link

<?php rewind_posts(); ?> rewinds post for a second loop



Extra Functions

Function Description

/%postname%/ custom permalinks

<?php include(TEMPLATEPATH . '/x'); ?> include file from template folder

<?php the_search_query(); ?> value returned from search from

<?php _e('Message'); ?> return translated text from translate()

<?php wp_register(); ?> register link

<?php wp_loginout(); ?> login/logout link

<!--nextpage--> divide content into pages

<!--more--> cut off content and create link to full
post


<?php wp_meta(); ?> admin meta data

<?php timer_start(); ?> start page timer (header.php)

<?php timer_stop(1); ?> time to load the page (footer.php)

<?php echo get_num_queries(); ?> show queries executed to generate
page