Send this to a friend
via http://codex.wordpress.org/Function_Reference/wp_insert_post
1 <?php
2
3 include "wp-blog-header.php";
4
5 $my_post = array();
6 $my_post['post_title'] = 'My post';
7 $my_post['post_content'] = 'This is my post.';
8 $my_post['post_status'] = 'publish';
9 $my_post['post_author'] = 1;
10 $my_post['post_category'] = array(13);
11
12 $post_id = wp_insert_post($my_post);
13
14 $post = get_post($post_id);
15 wp_redirect($post->guid);
16
17 ?>
<?php
include "wp-blog-header.php";
$my_post = array();
$my_post['post_title'] = 'My post';
$my_post['post_content'] = 'This is my post.';
$my_post['post_status'] = 'publish';
$my_post['post_author'] = 1;
$my_post['post_category'] = array(13);
$post_id = wp_insert_post($my_post);
$post = get_post($post_id);
wp_redirect($post->guid);
?>
Send this to a friend
1 <?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 10");
2 foreach ($result as $topten) {
3 $postid = $topten->ID;
4 $title = $topten->post_title;
5 $commentcount = $topten->comment_count;
6 if ($commentcount != 0) { ?>
7 <li><a href="<?php echo get_permalink($postid); ?>" title="<?php echo $title ?>"><?php echo $title ?></a></li>
8 <?php } } ?>
<?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 10");
foreach ($result as $topten) {
$postid = $topten->ID;
$title = $topten->post_title;
$commentcount = $topten->comment_count;
if ($commentcount != 0) { ?>
<li><a href="<?php echo get_permalink($postid); ?>" title="<?php echo $title ?>"><?php echo $title ?></a></li>
<?php } } ?>
Send this to a friend
1 <?php
2 $today = current_time('mysql', 1);
3 $howMany = 5;
4 if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_modified_gmt < '$today' ORDER BY post_modified_gmt DESC LIMIT $howMany")):
5 ?>
6 <ul>
7 <?php
8 foreach ($recentposts as $post) {
9 if ($post->post_title == '') $post->post_title = sprintf(__('Post #%s'), $post->ID);
10 echo "<li><a href='".get_permalink($post->ID)."'>";
11 the_title();
12 echo '</a></li>';
13 }
14 ?>
15 </ul>
16 <?php endif; ?>
<?php
$today = current_time('mysql', 1);
$howMany = 5;
if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_modified_gmt < '$today' ORDER BY post_modified_gmt DESC LIMIT $howMany")):
?>
<ul>
<?php
foreach ($recentposts as $post) {
if ($post->post_title == '') $post->post_title = sprintf(__('Post #%s'), $post->ID);
echo "<li><a href='".get_permalink($post->ID)."'>";
the_title();
echo '</a></li>';
}
?>
</ul>
<?php endif; ?>
Send this to a friend
1 <?php
2 include_once(ABSPATH.WPINC.'/rss.php');
3 wp_rss('http://mysite.com/feed', 5);
4 ?>
<?php
include_once(ABSPATH.WPINC.'/rss.php');
wp_rss('http://mysite.com/feed', 5);
?>
Send this to a friend
1 <?php query_posts('showposts=5'); ?>
2 <ul>
3 <?php while (have_posts()) : the_post(); ?>
4 <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
5 <?php endwhile;?>
6 </ul>
<?php query_posts('showposts=5'); ?>
<ul>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile;?>
</ul>
Send this to a friend
1 Results for: <?php $allsearch = &new WP_Query("s=$s&showposts=-1"); $key = wp_specialchars($s, 1); $count = $allsearch->post_count; echo $key . ' (' . $count . ')'; wp_reset_query(); ?>
Results for: <?php $allsearch = &new WP_Query("s=$s&showposts=-1"); $key = wp_specialchars($s, 1); $count = $allsearch->post_count; echo $key . ' (' . $count . ')'; wp_reset_query(); ?>
Send this to a friend
1 UPDATE wp_users
2 SET user_pass = MD5('password')
3 WHERE user_login = 'login';
UPDATE wp_users
SET user_pass = MD5('password')
WHERE user_login = 'login';
Send this to a friend
in your /wp-config.php
1 <?php
2
3 define('WP_POST_REVISIONS', false);
4
5 ?>
<?php
define('WP_POST_REVISIONS', false);
?>
Send this to a friend
1 DELETE a,b,c
2 FROM wp_posts a
3 LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
4 LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
5 WHERE a.post_type = 'revision'
DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision'
Send this to a friend
based on http://design.sparklette.net/teaches/how-to-add-wordpress-pagination-without-a-plugin/
1 <?php
2
3
4
5 function pagination($pages = '', $range = 4){
6 $showitems = ($range * 2)+1;
7
8 global $paged;
9 if(empty($paged)) $paged = 1;
10
11 if($pages == '') {
12 global $wp_query;
13 $pages = $wp_query->max_num_pages;
14 if(!$pages) {
15 $pages = 1;
16 }
17 }
18
19 if(1 != $pages) {
20 echo "Page ".$paged." of ".$pages;
21 }
22 }
23
24 ?>
25
26
27
28 <?php
29
30
31
32 if (function_exists("pagination")) { pagination($additional_loop->max_num_pages); }
33
34 ?>
<?php
function pagination($pages = '', $range = 4){
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '') {
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages) {
$pages = 1;
}
}
if(1 != $pages) {
echo "Page ".$paged." of ".$pages;
}
}
?>
<?php
if (function_exists("pagination")) { pagination($additional_loop->max_num_pages); }
?>