DFdou's Blog Life is short,Be yourself.

2512/092

WordPress-获取指定分类下的标签

函数体:

    function get_category_tags($args) {
        global $wpdb;
        $tags = $wpdb->get_results
        ("
            SELECT DISTINCT terms2.term_id as tag_id, terms2.name as tag_name, null as tag_link
            FROM
                wp_posts as p1
                LEFT JOIN wp_term_relationships as r1 ON p1.ID = r1.object_ID
                LEFT JOIN wp_term_taxonomy as t1 ON r1.term_taxonomy_id = t1.term_taxonomy_id
                LEFT JOIN wp_terms as terms1 ON t1.term_id = terms1.term_id,

                wp_posts as p2
                LEFT JOIN wp_term_relationships as r2 ON p2.ID = r2.object_ID
                LEFT JOIN wp_term_taxonomy as t2 ON r2.term_taxonomy_id = t2.term_taxonomy_id
                LEFT JOIN wp_terms as terms2 ON t2.term_id = terms2.term_id
            WHERE
                t1.taxonomy = 'category' AND p1.post_status = 'publish' AND terms1.term_id IN (".$args['categories'].") AND
                t2.taxonomy = 'post_tag' AND p2.post_status = 'publish'
                AND p1.ID = p2.ID
            ORDER by tag_name
        ");
        $count = 0;
        foreach ($tags as $tag) {
            $tags[$count]->tag_link = get_tag_link($tag->tag_id);
            $count++;
        }
        return $tags;
    }

wp_是表前缀,看需要改吧。
下边是调用方法:

$args = array('categories' => '12,13,14');
$tags = get_category_tags($args);
Tagged as: , 2 Comments
1712/090

WordPress – Gadgetizer Theme Released

来自http://designdisease.com的主题总是很精致,这次带来的是Gadgetizer Theme:

Gadgetizer

点击查看在线Demo
下边是来自官方那个的介绍:

Gadgetizer is exactly what it sounds like it would be about. Gadgets. We wanted a simple theme that focused on the products themselves, so we have a big Flickr area in the footer section, as well as a mashup of images right below the featured post. As always, the front page has an easy to use “feature” section so you can easily put on display your most in-depth posts. You can even slot in a nice picture and a post excerpt to accompany the headline by editing the feature-image custom field and setting the category to “Featured”.

We kept it pretty similar in color scheme to the last design, with the colors white, blue, and green. Also we have included the psd files for the logo, robo girl, and for the gadgets snapshots.

The theme is fully widgetized. A special feature of this theme as we use in many of our themes is the logo changer. You can use the default WordPress setting (“blog name”) or you can use your own logo. Upload your logo in the root folder of Gadgetizer theme and name it logo.png or you can use the logo.psd as a template. You will find the source in the root folder of the Tipz theme.

This theme also has a large footer bar that includes a links section, Flickr photostream, and latest comments section. Because some people might not like this option, we also included in the theme options the ability to have this section not show up.

The theme is using a few plugins, with some already integrated into functions.php, so there is no need to install them. The only plugin you need to install manually is FlickrRSS.  (FlickrRSS plugin is in the theme folder) (see the demo).

gadgetizer-2

Tagged as: No Comments
1711/090

WordPress-AppCloud主题

推荐个主题,AppCloud:
AppCloud
是商城类型的模板,看起来改造成自己用的模板也还不错,有兴趣的可以看下,不过记得看下版权,版权啊版权。
Demo地址:http://demo.icreativelabs.com/ecommerce/
Download地址:http://portfolio.icreativelabs.com/wp-content/plugins/download-monitor/download.php?id=Download+Appcloud

2110/092

WordPress-Tipz Theme Released

Learned from http://designdisease.com/blog/tipz-theme-released/?utm_source=rss&utm_medium=rss&utm_campaign=tipz-theme-released
designdisease.com又发布了一款Theme,这款主题颜色比较热情,挺好的,下边是Demo和下载地址。

We wanted a good strong theme that could fit a wide variety of topics for Tipz, which mainly writes how-to articles among various other topics. The front page has an easy to use “feature” section so you can easily put on display your most in-depth posts. You can even slot in a nice picture and a post excerpt to accompany the headline by editing the feature-image custom field and setting the category to “Featured”. We always like our rounded corners, which give the theme a simple Web 2.0 feel.

tipztheme

The theme is fully widgetized. A special feature of this theme as we use in many of our themes is the logo changer. You can use the default WordPress setting (“blog name”) or you can use your own logo. Upload your logo in the root folder of Tipz theme and name it logo.png or you can use the logo.psd as a template. You will find the source in the root folder of the Tipz theme..

This work is licensed Creative Commons Attribution-Share Alike 3.0 License. This means you may use it, and make any changes you like. Just leave the credits on footer if you respect the designer’s work.

Enjoy !

2109/090

LapOfLuxury Theme Released

designdisease每次出品的Theme都比较经典,这次是LapOfLuxury
lapofluxury1
Demo地址:http://www.lapofluxury.com/

Tagged as: No Comments
2307/090

WordPress – .htaccess的10个绝佳应用

内容转载自:< .htaccess在wordpress中的10个绝佳应用>:
.htaccess文件可以控制Apache Webserver,它非常实用我们可以通过它来实现很多功能。在这篇文章中我们可以看到通过修改.htaccess文件来增强wordpress的功能、安全性、可用性.

警告:在修改.htaccess文件时请确保已经备份以防不测

1.重定向Wordpress默认Rss地址到Feedburner

Feedburner是Google提供的Feed托管服务,非常优秀,如果不是受到国内“墙”的影响Feedsky也不会在国内一家独大。如果我们想手动修改wordpress文件来实现Feedburner替代默认Rss,过程非常繁琐,不过现在没有那么麻烦了,我们可以通过修改.htaccess来轻松实现该功能.

# temp redirect wordpress content feeds to feedburner
<ifmodule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{HTTP_USER_AGENT} !FeedBurner    [NC]
 RewriteCond %{HTTP_USER_AGENT} !FeedValidator [NC]
 RewriteRule ^feed/?([_0-9a-z-]+)?/?$ http://feeds2.feedburner.com/jomor [R=302,NC,L]
</ifmodule>

使用时别忘了把代码中的Feedburner地址替换为自己的

2.在wordpress的url中去除/category/

wordpress默认的category的永久链接形式是这样的:

http://yourblog.com/category/wordpress

这样看来,category似乎在url中显的多余,我们可以修改.htaccess来把他去除.

RewriteRule ^category/(.+)$ http://www.yourblog.com/$1 [R=301,L]

DFdou注:这里也可以使用一个叫Top Level Categories的插件可以解决这个问题,不过要搭配Permalink Redirect Plugin.
修改过后链接就会变成这个样子了:http://yourblog.com/wordpress.

1507/091

WordPress-wp_mail()函数

有时候在自定义主题的时候,会用到发邮件的功能,这个时候可能就需要用到这个函数了。
wp_mail()函数是WP用来发邮件的一个函数,类似于PHP的mail(),函数定义如下:

function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ){
	// Compact the input, apply the filters, and extract them back out
	extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) );

	if ( !is_array($attachments) )
		$attachments = explode( "\n", $attachments );

	global $phpmailer;

	// (Re)create it, if it's gone missing
	if ( !is_object( $phpmailer ) || !is_a( $phpmailer, 'PHPMailer' ) ) {
		require_once ABSPATH . WPINC . '/class-phpmailer.php';
		require_once ABSPATH . WPINC . '/class-smtp.php';
		$phpmailer = new PHPMailer();
	}

	// Headers
	if ( empty( $headers ) ) {
		$headers = array();
	} else {
//...下边省略..............
//具体文件在WP根目录下wp-mail.php

$to是要发送的email地址,$subject是主题,$message是邮件内容,$headers比较复杂,可以这样设置

$headers = 'From: '. get_option('blogname') .' < ' . get_option('admin_email') . '>';
//尖括号前边有个空格,不要忘记了!

get_option('blogname')就是博客名了,get_option('admin_email')是admin的邮箱地址。还可以设置content-type,charset等参数。
当然了,需要使用wp_mail()函数,就需要成为WP的模板页(这个做法比较方便),或者手动导入全部需要的类文件(不推荐)。
参考资料:《Phpmailer的用法》

Tagged as: , 1 Comment
607/091

WordPress-一些奇怪的错误Some Special Error

1.打开PHP页面,出现500错误。
用WP开发的时候碰到个奇怪的问题,3个wp-开头的文件夹下的全部PHP文件都无法访问,报500错误。
到底是个怎么回事呢,原来是因为文件的权限设置不当导致的,777的属性在某些系统下就会出现这个鬼问题!
建议解决方法,修改wp-开头的文件夹权限为755,里边的文件建议改成644属性。当然,uploads文件夹例外。
2.Warning: implode() [function.implode]: Invalid arguments passed in xxx(your url)/post.php on line 1762
在编辑page的时候会出现这个问题,但是post里却一切正常,恩,这个是升级2.8造成的问题,可能的原因有插件冲突,文件带了dom标志等等。
如果是插件冲突,请关闭插件。如果是文件带了dom标志,去DW里去掉。如果是升级2.8造成的,重新上传wp-include下边的文件,如果还不能解决问题,重新传全部文件吧……

3006/090

WordPress-2次开发常用函数

全函数列表请参见这里:《WordPress模板标签Template_Tags》
这里只列出最常用的几个。先是重要的bloginfo(),不直接echo数值的函数为get_bloginfo();恩,不少函数都是按照这个规则写的,PS:并不是全部!echo出函数值的函数为xxx()的话,那么不echo出结果值的的函数为get_xxx()。
该函数范围的是WordPress的配置参数,主要参数和值举例如下,常用的黑体标出:

admin_email = admin@example
atom_url = http://example/home/feed/atom
charset = UTF-8
comments_atom_url = http://example/home/comments/feed/atom
comments_rss2_url = http://example/home/comments/feed
description = Just another WordPress blog
home = http://example/home这个是网站首页地址
html_type = text/html
language = en-US
name = Testpilot网站名称
pingback_url = http://example/home/wp/xmlrpc.php
rdf_url = http://example/home/feed/rdf
rss2_url = http://example/home/feed
rss_url = http://example/home/feed/rss
siteurl = http://example/home也是网站地址
stylesheet_directory = http://example/home/wp/wp-content/themes/largo
stylesheet_url = http://example/home/wp/wp-content/themes/largo/style.css主题文件夹下的style.css地址
template_directory = http://example/home/wp/wp-content/themes/largo主题包地址
template_url = http://example/home/wp/wp-content/themes/largo
text_direction = ltr
url = http://example/home
version = 2.7
wpurl = http://example/home/wp
举例,bloginfo("wpurl ")会输出“http://example/home/wp”。

2906/090

WordPress-Theme的制作

以下内容建立在有部分HTML基础下,如果有疑问可以Twitter我,EMAIL我,MSN我,留言我,电话我,etc,但是不要QQ我~
WP的主题所在文件夹为XXX\wp-content\themes\,里边每个包都是目录(如果正常的话)。
先来讲下主题的组成,可以先参考这个文章《WordPress -Template System模板系统》
从该文章中我们可以发现,最最最简单的WP皮肤只需要一个文件,index.php,出于维护和多方合作开发以及修改的简便性来说,个人觉得一个主题至少应该分成以下几个部分:
header.php,里边放HTML的头部,一般是包含文档声明到body开始处,有时候也会包含菜单部分。

< !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">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>< ?php bloginfo('name'); ?> < ?php if ( is_single() ) { ?> Blog Archive < ?php } ?> < ?php wp_title(); ?></title>
..................
<body>

2206/090

WordPress Themes-BranfordMagazine

BranfordMagazine
这是一款来自der-prinz.com的CMS主题皮肤,比较简单,轻便,可定制性也非常的强。
浏览器兼容性Getested in - Firefox - Internet Explorer 7 - Internet Exporer 6 - Opera
下边是:
Demo+++++++++++Download+++++++++++Support Forum+++++++++++Tutorials

1906/090

介绍下WordPress

先来讲下WordPress是什么

来自WordPress官方的介绍如下:

WordPress is a state-of-the-art publishing platform with a focus on aesthetics, web standards, and usability. WordPress is both free and priceless at the same time.
More simply, WordPress is what you use when you want to work with your blogging software, not fight it.

WordPress是一个可用性强,遵循WEB标准的免费的内容发布平台,而简单的用途则是用它来搭建博客系统,恩,一个支持多用户的博客系统。
PS:关于wordpress.org和wordpress.com的区别,org是发布wordpress新版本,开发动向,插件,皮肤和其他关于wordpress技术方面的东西。而com则是一个博客平台,大家可以在上边搭建免费的个人博客,类似的服务国内很多,如新浪博客,网易博客。由于某些政治原因,不推荐在wordpress.com开博,一年里头没有几天是不被GFW的。

406/090

15款WordPress角色权限管理插件 | 转载自帕兰映像

曾经有个工作里边接触到了WP后台权限的问题,发现WP自身的角色实在是太少了,今天看到帕兰的这个内容,转载一下。
以下内容转载自 15款WordPress角色权限管理插件 | 帕兰映像
对于开放性注册的WordPress博客来说, 我们已经介绍过13款WordPress用户注册登录插件,但注册后的权限分配管理也是很重要的。下面,就请看看这15款WordPress角色权限管理插件
Role Manager WordPress Plugin
这应该是目前最强大的一款WordPress角色管理插件,使用它,你可以:

  • 修改现有角色等级的名称。你可能并不需要”订阅者、编辑者、供稿者”这样的角色名称,而想用”探花,举人,状员”之类的。
  • 你还可以新建多个角色等级,并为每个等级的角色分配不同的权限,你甚至可以为同等级中的某一用户分配不同的权限。
  • 自定义角色等级的权限

总之,这是一款用户管理的首选插件。

2105/091

WordPress-100 Amazing Free Wordpress Themes for 2009

one room
Learned from 《100 Amazing Free Wordpress Themes for 2009》
The last few days in review for NCRE,so,have not so much time to update blog,and,,oh,maybe i will update something interesting from other website,today's topic,,haha,Free Wordpress Themes,do some one use wordpress too..
WordPress is an easy and free blog system,you can build blog quickly with it.

705/092

WordPress Plugins-WP Super Cache使用介绍

今天正好在弄针对YSlow的优化,唉,分数一直是E,无语的很,怎么也减不了,放弃了。趁这会用了下WP Super Cache插件,效果还不错。
下边内容来自http://fairyfish.net/2008/10/27/wp-super-cache/
WP Super Cache 基本介绍
WP Super Cache 是 WordPress 官方开发人员 Donncha 开发,是当前最高效也是最灵活的 WordPress 静态缓存插件。它直接生成 HTML 文件,能使得你的 WordPress 博客将显著的提速。
下载 WP Super Cache 后,上传到插件目录,并在 Plugin 目录下激活之后,接着需要在 Setting > WP Super Cache 进行详细配置。
WP Super Cache Status
首先是三个选项:
* ON (WP Cache and Super Cache enabled)
* HALF ON (Super Cache Disabled, only legacy WP-Cache caching.)
* OFF (WP Cache and Super Cache disabled)
默认情况下,WP Super Cache 是没有开启的,所以在这里选择下,需按则第一个,就是 Super Cache,缓存为静态文件,如果第二种情况呢,则和 WP-Cache 一致。

Proudly tell the world your server is Digg proof! (places a message in your blog’s footer)
这个是说在你的 footer 显示一条信息告诉读者该博客已经缓存了,一般不要这样做。

Clear all cache files when a post or page is published. (This may significantly slow down saving of posts.)
这个是说发布新日志的时候清理所有缓存,这个肯定不能这么干了。

Page 1 of 41234