找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
积分等级发帖收益的说明江阴论坛帮助汇总江阴论坛管理规则(必看)江阴论坛版主招聘中江阴论坛已运行
查看: 1667|回复: 0

[WordPress] 在非wp目录调用最新文章和摘要

[复制链接]
发表于 2009-5-22 09:53:11 | 显示全部楼层 |阅读模式
  1. <?php
  2. require_once('blog/wp-config.php');
  3. function get_recent_posts($no_posts = 6, $before = '+ ', $after = '<br>', $show_pass_post = false, $skip_posts = 0) {
  4.     global $wpdb, $tableposts;
  5.     $request = "SELECT ID, post_title, post_date, post_content FROM $tableposts WHERE post_status = 'publish' ";
  6.         if(!$show_pass_post) { $request .= "AND post_password ='' "; }
  7.     $request .= "ORDER BY post_date DESC LIMIT $skip_posts, $no_posts";
  8.     $posts = $wpdb->get_results($request);
  9.     $output = '';
  10.     foreach ($posts as $post) {
  11.      
  12.         $post_title = stripslashes($post->post_title);
  13. //  $post_date = mysql2date('j.m.Y', $post->post_date);
  14.         $permalink = get_permalink($post->ID);
  15.   $post_content = stripslashes($post->post_content);
  16.         $output .= $before . '<a href="' . $permalink . '" rel="bookmark" title="Permanent Link: ' . $post_title . '">' . $post_title . '</a>'. $after;
  17.   $output .= $before .  $post_content .$after;
  18.   
  19.     }
  20.     echo $output;
  21. }
  22. function mul_excerpt ($excerpt) {
  23.      $myexcerpt = substr($excerpt,0,255);
  24.      return utf8_trim($myexcerpt) . '... ';
  25. }
  26. get_recent_posts();
  27. ?>
复制代码
转自:http://wordpress.org.cn/thread-27086-1-1.html
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|江阴人家

GMT+8, 2024-11-24 02:16 , Processed in 0.036510 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表