Listed below is the code that I use most in WordPress. I will be adding to it on an ongoing basis. If you have a question about how to use any of the code please feel free to add a comment at the bottom of the page.
http://yourURL.com/wp-content/themes/yourThemeName
Example:
<img src="<?php echo bloginfo('template_directory').'/images/title.gif'; ?>">
is the same as:
<img src="http://yourURL.com/wp-content/themes/yourThemeName/images/title.gif">
<?php $image = get_post_meta($post->ID, 'image', TRUE); ?>
<?php if($image) { ?><img src="<?php echo $image; ?>" alt="Alt Text" /><?php } ?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<?php endwhile; // end of the loop. ?>
If the page title is Contact then this will execute
}
<?php query_posts('category_name=
Category&showposts=10'); ?>
<?php while (have_posts()) : the_post(); ?>
// The Stuff... Custom HTML & PHP Code
<?php endwhile;?>
<?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('category_name=blog&showposts=10'.'&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<!--Print out the info -->
<div class="blogtitle"><a href="<?php the_permalink() ?>"><h2><?php the_title() ?></h2></a></div><div class="blogtime"><?php the_time() ?> | <?php the_date() ?> | <?php the_author(); ?> | <?php the_tags(); ?></div>
<?php $image = get_post_meta($post->ID, 'image_home', TRUE); ?>
<div class="blogimage"><a href="<?php the_permalink() ?>"><img src="<?php echo '/'.$td.'/scripts/timthumb.php?src=/'.$image.'&h=0&w=445&zc=1' ?>" /></a></div>
<div class="blogexcerpt"><?php the_excerpt() ?></div>
<div class="bloghr"><hr></hr></div>
<?php endwhile; ?>
<div class="blogpage"><?php pagination( $wp_query, "/" ); ?></div>
<?php $wp_query = null; $wp_query = $temp;?>
function pagination( $query, $baseURL ) {
$page = $query->query_vars["paged"];
if ( !$page ) $page = 1;
$qs = $_SERVER["QUERY_STRING"] ? "?".$_SERVER["QUERY_STRING"] : "";
// Only necessary if there's more posts than posts-per-page
if ( $query->found_posts > $query->query_vars["posts_per_page"] ) {
echo '<ul class="paging">';
// Previous link?
if ( $page > 1 ) {
echo '<li class="previous"><a href="'.$baseURL.'blog/page/'.($page-1).'/'.$qs.'">previous</a></li>';
}
// Loop through pages
for ( $i=1; $i <= $query->max_num_pages; $i++ ) {
// Current page or linked page?
if ( $i == $page ) {
echo '<li class="active">'.$i.'</li>';
} else {
echo '<li><a href="'.$baseURL.'blog/page/'.$i.'/'.$qs.'">'.$i.'</a></li>';
}
}
// Next link?
if ( $page < $query->max_num_pages ) {
echo '<li><a href="'.$baseURL.'blog/page/'.($page+1).'/'.$qs.'">next</a></li>';
}
echo '</ul>';
}
}
<?php /* Template Name: Home */ ?>
if (in_category(‘Web’)
In you functions.php file there is a function called “function your theme-name_comment”
Find the line:
<?php echo get_avatar( $comment, 40 ); ?>
Replace with:
$author = get_comment_author_link();
if ($author == "admin"){
echo get_avatar( 'your admin email', $size = '40', $default = 'url to image' );
}
if ($author != "admin"){
echo get_avatar( $comment, 40 );
}
