1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
FORMAT CHARACTERS FOR THE ‘DAY’
D = abbreviated day of the week: e.g. Mon, Tue, Sun, etc.
d = date displayed as two digits, and single digit dates are led by a zero
j = date displayed as one digit
l (lowercase L) = full day of the week: e.g. Monday, Tuesday
N = number representing the day of the week: e.g. Mon.=>1
S = suffix for numeric day of the month: e.g. st, nd, ect.
z = number representing the day of the year: 0-365
FORMAT CHARACTERS FOR THE ‘WEEK’
W = number representing the number of the week: ’32′ week of year
FORMAT CHARACTERS FOR THE ‘MONTH’
F = full month: e.g. May, June
m = two digit number representing month, single digit dates are led by a zero
M = abbreviated month: e.g. Dec, June, etc.
n = one digit month
FORMAT CHARACTERS FOR THE ‘YEAR’
Y = four digit year: 2009
y = two digit year: 09
FORMAT CHARACTERS FOR THE ‘TIME’
g = one digit, 12-hour hour format
G = one digit, 24-hour hour format
h = two digit, 12-hour hour format
H = two digit, 24-hour hour format
a = lowercase am or pm
A = uppercase AM or PM
i = two digit, minutes
s = two digit, seconds
<?php the_time('l, F jS, Y') ?>
F j, Y g:i a - November 6, 2010 12:50 am
F j, Y - November 6, 2010
F, Y - November, 2010
g:i a - 12:50 am
g:i:s a - 12:50:48 am
l, F jS, Y - Saturday, November 6th, 2010
M j, Y @ G:i - Nov 6, 2010 @ 0:50
Y/m/d \a\t g:i A - 2010/11/06 at 12:50 AM
Y/m/d \a\t g:ia - 2010/11/06 at 12:50am
Y/m/d g:i:s A - 2010/11/06 12:50:48 AM
Y/m/d - 2010/11/06
When you plan to add image as a custom field then you first need to enable custom field option. In recent wordpress versions custom field option is hidden by default. Click on the Screen Options
Then enable custom field option as show in image below.
Now you need to give a variable name undr Name column. We have chosen image_url and at the place of Value, put exact image path.
Now to call that variable from custom field you need to put below code.
1 2 3 4 5
<?php $img = get_post_meta($post->ID, "image_url", true); ?> //fetching value of image_url from wordpress post database and assigning it to $img variable. //Below code simply showing the value to display that image. <img src="<?php echo $img;?>" />
This code will show all recent comments.If you want to show some of the comments you have to edit in “LIMIT 10″;”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
<?php
global $wpdb;
$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID,
comment_post_ID, comment_author, comment_date_gmt, comment_approved,
comment_type,comment_author_url,
SUBSTRING(comment_content,1,30) AS com_excerpt
FROM $wpdb->comments
LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID =
$wpdb->posts.ID)
WHERE comment_approved = '1' AND comment_type = '' AND
post_password = ''
ORDER BY comment_date_gmt DESC
LIMIT 10";
$comments = $wpdb->get_results($sql);
$output = $pre_HTML;
$output .= "\n<ul>";
foreach ($comments as $comment) {
$output .= "\n<li>".strip_tags($comment->comment_author)
.":" . "<a href=\"" . get_permalink($comment->ID) .
"#comment-" . $comment->comment_ID . "\" title=\"on " .
$comment->post_title . "\">" . strip_tags($comment->com_excerpt)
."</a></li>";
}
$output .= "\n</ul>";
$output .= $post_HTML;
echo $output;
?>
Using this code you can get the recent post of a partivular category.You can show number of post you want to show by editing the value “‘numberposts=5″ .You have to add the category id in “category=1″.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
<ul>
<?php
global $post;
$myposts = get_posts('numberposts=5&offset=1&category=1');
foreach($myposts as $post) :
setup_postdata($post);
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
1 2 3 4 5 6 7 8 9 10 11
<?php
$rand_posts = get_posts('numberposts=4&orderby=');
foreach( $rand_posts as $post ) :
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
Copyright © 2010 PHP code. net. All Rights Reserved. Designed By: Web Design Company