Skip to content

Instantly share code, notes, and snippets.

@ivanteoh
ivanteoh / 59-404.php
Created July 5, 2020 04:58
WordPress Theme Development 9 - 404 Template
<?php
/**
* @package WordPress
* @subpackage Your_Theme
*/
?>
<?php get_header(); ?>
<h2><?php _e('Error 404 - Not Found'); ?></h2>
<?php get_search_form(); ?>
@ivanteoh
ivanteoh / 58-searchform.php
Created July 5, 2020 04:54
WordPress Theme Development 8 - Search Form
<?php
/**
* @package WordPress
* @subpackage Your_Theme
*/
?>
<form id="searchform" method="get" action="<?php bloginfo('home'); ?>">
<label for="s"><?php _e('Search'); ?></label><br />
<input id="s" type="text" name="s" value="<?php the_search_query(); ?>" />
<input id="searchsubmit" type="submit" value="<?php _e('Search'); ?>" />
@ivanteoh
ivanteoh / 57-comments.php
Created July 5, 2020 04:51
WordPress Theme Development 7 - Comments
<?php
/**
* @package WordPress
* @subpackage Your_Theme
*/
?>
<!-- Comments for WP 2.7 and more -->
<?php
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' ==
basename($_SERVER['SCRIPT_FILENAME']))
@ivanteoh
ivanteoh / 56-functions.php
Created July 5, 2020 04:47
WordPress Theme Development 6 - Theme Functions
<?php
/**
* @package WordPress
* @subpackage Your_Theme
*/
if ( function_exists('register_sidebar') )
register_sidebar(array(
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '',
@ivanteoh
ivanteoh / 55-sidebar.php
Created July 5, 2020 04:45
WordPress Theme Development 5 - Sidebar
<?php
/**
* @package WordPress
* @subpackage Your_Theme
*/
?>
<!-- begin sidebar -->
<ul>
<?php /* Widgetized sidebar, if you have the plugin installed. */
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
@ivanteoh
ivanteoh / 54-footer.php
Created July 5, 2020 04:39
WordPress Theme Development 4 - Footer
@ivanteoh
ivanteoh / 53-header.php
Created July 5, 2020 03:55
WordPress Theme Development 3 - Header
<?php
/**
* @package WordPress
* @subpackage Your_Theme
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head profile="http://gmpg.org/xfn/11">
@ivanteoh
ivanteoh / 52-index-after.php
Created July 5, 2020 03:51
WordPress Theme Development 2 - Minimum Main Index Template
<?php
/**
* @package WordPress
* @subpackage Your_Theme
*/
get_header(); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : ?>
<?php the_post(); ?>
<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
@ivanteoh
ivanteoh / 51-style.css
Created July 5, 2020 03:46
WordPress Theme Development 1 - Start with Theme Style Sheet
/*
Theme Name: Theme-Name
Theme URI: The-Theme-Web-Site
Description: The-Theme-Description
Version: The-Theme-Version
Author: Your-Name
Author URI: Your-Web-Site
General information if any.
License statement if any.
@ivanteoh
ivanteoh / 49-comments-after.php
Created July 5, 2020 00:26
Add Gravatar in WordPress Comments
<li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>">
<?php if(function_exists('get_avatar')) { echo get_avatar($comment, '50'); } ?>
<cite><?php comment_author_link() ?></cite> Says:
<?php if ($comment->comment_approved == '0') : ?>
<em>Your comment is awaiting moderation.</em>
<?php endif; ?>
<br />