<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>手机上学习与进步</title>
	<atom:link href="http://www.result-search.com/m/feed" rel="self" type="application/rss+xml" />
	<link>http://www.result-search.com/m</link>
	<description>高效利用时间的地方,欢迎注册</description>
	<lastBuildDate>Wed, 25 May 2011 10:20:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>discuz 5.5 插件设计</title>
		<link>http://www.result-search.com/m/lyman/233.html</link>
		<comments>http://www.result-search.com/m/lyman/233.html#comments</comments>
		<pubDate>Wed, 25 May 2011 10:20:14 +0000</pubDate>
		<dc:creator>lyman</dc:creator>
				<category><![CDATA[sina-api]]></category>

		<guid isPermaLink="false">http://www.result-search.com/m/?p=233</guid>
		<description><![CDATA[插件设计
您在开始论坛插件的设计之前，有必要了解一下我们所推荐的插件设计方式，更好的规范性和兼容性，将使得您设计的插件受到更多使用者的欢迎，对于程序员而言，也有助于形成良好的编码习惯，实现自身能力的提升。如果您有意编写 Discuz! 论坛插件，请按照先后顺序仔细阅读本文档。
准备工作
插件实现流程
    开始编写论坛插件，您应当首先对插件实现的流程有一个大致的了解，以下是我们推荐的插件编写流程：
        熟练使用 Discuz! 论坛系统后，对希望完善或补充的个性化功能进行评估，进而提出插件的功能需求。
        对插件做一个概括性的设计，例如：需要使用什么菜单、什么参数，配置哪些选项、数据结构如何设计、前后台实现哪些功能等等。
        阅读本文档并在系统设置中实际体验 Discuz! 插件接口所实现的功用，例如：您的插件应当如何设计才能良好的挂接到论坛系统中来。插件接口能够实现哪些功能、不能实现哪些功能，插件为此而需要做的优化、改造和取舍。
        编写相应程序代码和模板语句，实现所需的功能并进行代码测试、兼容性测试和代码改进。
        如果需要公开您的插件，可以用插件导出的方式，将插件配置信息导出到一个文本文件中，连同相应的程序和模板文件一同打包。同时，编写一个适合新手的插件的说明书也是必不可少的，其中包括：插件适用的 Discuz! 版本、功能概述、兼容性声明、安装方法、使用方法、卸载方法等等。
   [...]]]></description>
			<content:encoded><![CDATA[<p>插件设计</p>
<p>您在开始论坛插件的设计之前，有必要了解一下我们所推荐的插件设计方式，更好的规范性和兼容性，将使得您设计的插件受到更多使用者的欢迎，对于程序员而言，也有助于形成良好的编码习惯，实现自身能力的提升。如果您有意编写 Discuz! 论坛插件，请按照先后顺序仔细阅读本文档。</p>
<p>准备工作</p>
<p>插件实现流程</p>
<p>    开始编写论坛插件，您应当首先对插件实现的流程有一个大致的了解，以下是我们推荐的插件编写流程：</p>
<p>        熟练使用 Discuz! 论坛系统后，对希望完善或补充的个性化功能进行评估，进而提出插件的功能需求。<br />
        对插件做一个概括性的设计，例如：需要使用什么菜单、什么参数，配置哪些选项、数据结构如何设计、前后台实现哪些功能等等。<br />
        阅读本文档并在系统设置中实际体验 Discuz! 插件接口所实现的功用，例如：您的插件应当如何设计才能良好的挂接到论坛系统中来。插件接口能够实现哪些功能、不能实现哪些功能，插件为此而需要做的优化、改造和取舍。<br />
        编写相应程序代码和模板语句，实现所需的功能并进行代码测试、兼容性测试和代码改进。<br />
        如果需要公开您的插件，可以用插件导出的方式，将插件配置信息导出到一个文本文件中，连同相应的程序和模板文件一同打包。同时，编写一个适合新手的插件的说明书也是必不可少的，其中包括：插件适用的 Discuz! 版本、功能概述、兼容性声明、安装方法、使用方法、卸载方法等等。<br />
        将插件提供给他人，或自己使用，根据使用者反馈，对插件进行完善。插件实现流程至此结束。 </p>
<p>文件命名规范</p>
<p>    Discuz! 按照如下的规范对程序和模板进行命名，请在设计插件时尽量遵循此命名规范：</p>
<p>        可以直接通过浏览器访问的普通程序文件，以 .php 后缀命名。<br />
        被普通程序文件引用的程序文件，以 .inc.php 后缀命名。<br />
        被普通程序文件，或引用程序文件引用的函数库或类库，以 .func.php(函数库) 或 .class.php(类库) 后缀命名。<br />
        模板文件，以 .htm 后缀命名，模板文件只存在于 ./templates 目录中。<br />
        模板语言包文件，以 .lang.php 后缀命名，语言包文件只存放于 ./templates 目录中，与模板文件同级目录。<br />
        被编译后的模板文件，以 .tpl.php 后缀命名，前面的数字是模板套系的 ID，下划线后面的是模板原名，编译模板文件只存在于 ./forumdata/templates 目录中。<br />
        动态缓存文件，存放于 ./forumdata/cache 目录中，依据不同的功用进行独立的命名。<br />
        使用后台数据备份功能生成的备份文件，通常以 .sql 为后缀，存放于 ./forumdata/ 目录中。<br />
        有些目录中存在内容为空白的 index.htm 文件，此类文件是为了避免 Web 服务器打开 Directory Index 时可能产生的安全问题。 </p>
<p>common.inc.php 模块功能白皮书</p>
<p>    ./include/common.inc.php 是 Discuz! 的通用初始化模块程序，其几乎被所有的外部代码所引用，在您开始插件设计之前，可以先对该模块的大致功能做一定的了解。common.inc.php 主要完成了以下任务：</p>
<p>        对不同 PHP 及操作系统环境做了判断和兼容性处理，使得 Discuz! 可以运行于各种不同配置的服务器环境下。<br />
        初始化常量 IN_DISCUZ 为 TRUE，用于 include 或 require 后续程序的判断，避免其他程序被非法引用。<br />
        读取论坛所在绝对路径，存放于常量 DISCUZ_ROOT 中。<br />
        加载所需的基本函数库 include/global.func.php。<br />
        通过 config.inc.php 中提供的数据库账号信息，建立数据库连接。Discuz!支持数据表的前缀，如需获得表的全名，可使用”{$tablepre}tablename” 或 $tablepre.’tablename’的方式。<br />
        判断用户是否登录，如登录标记 $discuz_uid 为非 0，同时将 $discuz_user（加了 slash 的用户名，可用于不加修改的插入数据库）、 $discuz_userss（原始的用户名，可用于页面显示）、$discuz_pw（用户密码的MD5串）、$discuz_secques（登录提示问题的加密串）等相应用户信息赋值。<br />
        判断用户管理权限，将管理权限标记 $adminid 为 -1~3 中间的值。-1 代表为特殊用户组用户。0 代表普通用户；1 代表论坛管理员；2 代表超级版主；3 代表论坛版主。将用户权限按照其所在的主用户组 ID 标记为 $groupid，相关权限从该 $groupid 所对应的系统缓存中读出（./forumdata/cache/usergroup_$groupid.php）。将用户扩展权限按照其扩展用户组 ID 标记为 $extgroupids，中间以 \t（tab） 分隔，格式为“$groupid1\t$groupid2&#8230;”，扩展用户组用于确定用户的扩展浏览权限，例如能否访问某些有特殊权限设定的论坛等。<br />
        读入系统设置中的各种变量，并根据 Cache 模块的设定，根据当前被调用的程序文件名（如 index.php，forumdisplay.php 等等）读入相应的缓存代码。缓存代码被存放于 ./forumdata/cache/ 中。除了对应当前程序的缓存，可能还会加载一些通用的缓存数据，例如整个论坛的设置（./forumdata/cache/cache_settings.php）、界面风格（./forumdata/cache/style_x.php）、当前用户的用户组（./forumdata/cache/usergroup_x.php）、管理组权限（./forumdata/cache/adminusergroup_x.php）等。<br />
        缓存数据的格式，大多是存放在 $_DCACHE['cachename'] 数组中，有些常用的参数，如系统设置中的参数、风格界面等，通常还被进行了展开操作（extract）或使用常量进行赋值。<br />
        用户如果处在登录状态，会自动读出 members 表相关用户的参数值，用户的个性设置参数：如时差、时间格式、界面风格等等，会根据实际情况覆盖系统默认值，因此在后续程序通常不用再做判断。<br />
        如果程序提交的 URL 中包含 tid=x 或 fid=x，common.inc.php 模块会自动读出其所对应的论坛记录及包括 access masks、版主设定等相应权限，记录在 $forum 变量中。后续程序只要通过URL将tid或fid传递过来，便可通过 $forum 数组的存在性或相关参数来对论坛权限进行判断，不需要再读 forums 表的资料。 </p>
<p>插件接口概述</p>
<p>使用管理员账号登录 Discuz! 系统设置，在左侧菜单将可以看到“插件设置”和“插件管理”两个选项，使用超级版主或版主账号登录，将只出现“插件设置”一个选项。“插件管理”是控制插件打开与否、设计插件模块、菜单、参数和使用权限的地方，插件开发者可以依照设计意图，在此进行插件的初步设置，这里同时也提供插件导入和插件开关的功能，用于导入他人设计的插件和对插件的可用状态进行变更。“插件设置”是对已经安装的插件进行设置的地方，供使用者对插件参数进行调整以实现不同的插件功能。即前者主要面向开发者，后者主要面向使用者。</p>
<p>开始编写一个新插件，请首先在插件管理中，输入新插件的名称和惟一标识符。名称用于表明此插件的用途，例如设置为“虚拟银行插件”。惟一标识符用于在后续的插件模块中调用本插件，不可与现有插件重复，命名规则限制与 PHP 变量命名相同，虽然初次设置后仍可改动，但强烈建议一次性将此配置设置好，否则可能涉及到很多代码方面的变更，增加编码的麻烦。请注意：惟一标识符请不要设置的过短，或使用有可能与其他插件重复的命名，例如制作此插件的公司叫做 Comsenz Inc.，插件名称是“虚拟银行插件”，惟一标识符可设置为“comsenz_virtual_bank”，后面将以“虚拟银行插件”和“comsenz_virtual_bank”为例进行说明。</p>
<p>在插件管理中添加插件后，仅仅是增加了一条插件记录，后面还需要很多相关的设计和设置。在列表中选择插件的“详情”进入插件的详细设置。插件设置分为三个部分：</p>
<p>    插件基本设置：<br />
    设置插件的基本参数，配置项目右边括号中的内容，为此设置对应的参数名称，调用方法将在后面的《参数读取与缓存控制》中详细说明。</p>
<p>    插件模块和自定义菜单：<br />
    插件接口默认提供四种可选的模块方式：<br />
        直接链接（前台菜单）：可在前台右上角加入一个菜单项，可自主指派菜单链接的 URL。注意：由于引用外部程序，因此即便设置了模块的使用等级，您的程序如需权限判断，仍需要引用 common.inc.php 和插件相关的缓存文件（将在后面的《参数读取与缓存控制》中详细说明），并自行判断使用等级是否合法。<br />
        前台调用（前台菜单）：与直接链接类似，但其调用的是插件的一个模块，模块文件名指派为“./plugins/插件目录/插件模块名.inc.php”，由 plugin.php 调用此模块，调用 URL 将在后面的《编写插件的原则与注意事项》中详细说明。<br />
        后台调用（后台菜单）：可在后台插件设置中为此插件增添一个管理模块，模块文件名指派为“./plugins/插件目录/插件模块名.inc.php”，由 admincp.php 调用此模块，调用 URL 将在后面的《编写插件的原则与注意事项》中详细说明。<br />
        包含运行（无菜单）：可设置一个在论坛所有页面均包含运行的脚本，此脚本在 ./include/common.inc.php 中加载，脚本文件名指派为“./plugins/插件目录/插件模块名.inc.php”。请注意，为了不导致错误的插件影响论坛运行，在 common.inc.php 加载此模块时，屏蔽了错误信息，因此请务必仔细检查是否存在语法错误，任何微小的语法错误都将不被提示出来，并且导致此模块不被正常加载。如果您配置了不正确的包含脚本而导致论坛系统设置无法使用，删除服务器上相应的脚本文件即可解决。<br />
    您可以为每个模块设置不同的使用等级，例如设置为“超级版主”，则超级版主及更高的管理者（例如论坛管理员）可以使用此模块。</p>
<p>    插件钩子设置：<br />
    插件钩子能够将插件代码埋藏在程序中的任意位置，从而实现更加灵活的插件功能，最大限度的减少对原有程序代码的修改。 论坛版本升级后，只需将相应钩子重新埋入相应程序中，原有插件即可继续使用。 关于插件钩子的具体设计方法请见下面的《插件钩子的设计》。</p>
<p>    插件变量配置：<br />
    插件接口中提供了一个通用的插件配置管理程序，在大多数情况下可实现插件的参数配置，省却了插件开发者自行编写后台管理模块（即上面提到的“后台调用（后台菜单）”模块）的麻烦。通常情况下，应优先使用通用插件配置管理程序来实现插件的参数配置，只有在通用程序确实无法实现时，才自行编写后台管理模块。输入配置名称和配置变量名、选择合适的配置类型后，即可为此插件增加一个配置变量，点“详情”可以编辑此配置变量的更多信息。为了方便插件程序调用使用者配置好的参数，配置变量同样被存放在了缓存文件中，读取方法将在后面的《参数读取与缓存控制》中详细说明。</p>
<p>    注意：您只有在插件管理中将插件设置为“可用”，以上设置才能生效。 </p>
<p>参数读取与缓存控制</p>
<p>编写插件程序时，可能需要读取一些插件的信息，如果插件需要使用者进行配置，还需要读取使用者设置的参数值。Discuz! 允许插件程序使用数据库读取和缓存读取这两种方法获取插件信息和参数。Discuz! 的插件接口已经对插件信息进行了合理的缓存，使用缓存读取的方式，将比数据库读取速度更快，消耗的资源更是几乎可以忽略不计。缓存读取唯一的局限是需要插件使用插件接口提供的通用后台管理程序。如果使用自定义后台模块的方式，需要后台模块将参数存放到 pluginvars 数据表中，才能被系统正常缓存。我们强烈推荐您通过缓存读取插件信息和配置数据。</p>
<p>插件数据结构</p>
<p>    插件数据使用两个数据表存放，分别是 plugins 和 pluginvars。前者用于存放插件信息：安装了多少个插件，就有多少条记录；后者用于存放插件的配置参数和配置值：所有已安装的插件总共有多少个配置项目，就有多少条记录。下面的表格列出了这两个表的主要字段及其用途说明。</p>
<p>    plugins 表：</p>
<p>    	pluginid		插件的惟一 ID，自动递增<br />
    	available	插件是否可用，1=是，0=否<br />
    	adminid		使用系统设置中插件接口自带的插件参数设置程序所需的最低权限等级要求，1=管理员，2=超级版主，3=版主<br />
    	name		插件名称<br />
    	identifier	插件惟一标识符<br />
    	description	插件简介<br />
    	datatables	插件数据表，不包含前缀，多个表使用半角逗号“,”分隔<br />
    	directory	插件所在目录，例如设置为 comsenz_bank，则对应论坛目录的位置为 ./plugins/comsenz_bank/<br />
    	copyright	插件版权信息<br />
    	modules		插件模块信息，数组格式，使用 serialize() 序列化后存放</p>
<p>    pluginvars 表：</p>
<p>    	pluginvarid	插件配置的惟一 ID，自动地增<br />
    	pluginid		本项配置所隶属的插件 ID<br />
    	displayorder	本项配置的显示顺序，数值低的排在前面<br />
    	title		插件配置的名称<br />
    	description	插件配置的简介<br />
    	variable		插件配置的变量名<br />
    	type		插件配置的类型<br />
    	value		插件配置的值<br />
    	extra		当本项配置为“选择（select）”时，可选的取值范围</p>
<p>    如果您使用自行编写的插件后台管理模块进行插件参数配置，请尽量将配置项目按照 pluginid 的对应关系，将参数存储于 pluginvars 表中，这样系统就可以自动将您增加的配置参数缓存起来，以供插件程序进行调用。 </p>
<p>插件参数读取</p>
<p>    了解了 Discuz! 插件存储的数据结构后，您可以在插件程序中根据需要选择合适的数据读取方式。由于数据库读取方式可以由数据结构推断而来，因此这里只介绍缓存读取的方式，这种方式是我们强烈推荐的插件数据读取方式。</p>
<p>    在管理者配置好插件信息，或用户进行插件的参数设置之后，系统将根据插件设置的惟一标识符，自动生成一个插件数据的缓存文件，例如惟一标识符为 comsenz_virtual_bank，则缓存文件位于 ./forumdata/cache/plugin_comsenz_virtual_bank.php，您可以打开此文件查看其中的数据内容和格式。缓存采用数组的方式进行存储，引用此文件即可将所需的插件参数一次性赋值。</p>
<p>    其中，$_DPLUGIN['comsenz_virtual_bank'] 这个数组下标，为插件的惟一标识符，所有插件缓存数据，一经被引用，就会赋值到 $_DPLUGIN 这个多维数组中。modules 描述了这个插件的模块信息，其中 type 为 1~4 的整数值，从小到大依次为“直接链接(前台菜单)”、“前台调用(前台菜单)”、“后台调用(后台菜单)”、“包含运行(无菜单)”；vars 描述了这个插件的配置变量，前面为变量名，后面为使用者赋予这个变量的值。 </p>
<p>编写插件的原则与注意事项</p>
<p>请在您动手编写插件之前，还需要仔细的阅读以下原则，遵循这些原则，将有效的避免可能发生的问题：</p>
<p>    所有与插件的程序，包括其全部的前后台程序，请全部放入 ./plugins 目录中，同时在插件的安装说明中指出，插件的文件需要复制到哪些目录。为了避免与其他插件冲突，请尽量建立 ./plugins 下的子目录，并将插件程序放置于子目录下，这样您编写的插件将获得更好的兼容性。<br />
    如果您的插件包含“前台调用（前台菜单）”模块，该模块将统一用 plugin.php?identifier=xxx&#038;module=yyy 的方式调用，请在相应链接、表单中使用此方式。其中 xxx 为插件的惟一标识符，yyy 为模块名称。前台插件外壳程序 plugin.php 已经加载了通用初始化模块（./include/common.inc.php），不需再次引用。<br />
    如果您的插件包含“后台调用（后台菜单）”模块，该模块将统一用 admincp.php?action=plugins&#038;identifier=xxx&#038;mod=yyy 的方式调用，请在相应链接、表单中使用此方式。其中 xxx 和 yyy 的定义与“前台调用（前台菜单）”模块中的相同。系统还允许用 admincp.php?action=plugins&#038;edit=$edit&#038;mod=$mod 的方式来生成链接和表单地址，$edit 和 $mod 变量已经被插件后台管理接口赋值，因此将这两个变量值带入 URL 中也是被支持的。由于后台模块是被 admincp.php 调用，因此已加载了通用初始化模块（./include/common.inc.php）并进行了后台管理人员权限验证，因此模块程序中可直接写功能代码，不需再进行验证。<br />
    请勿绕过插件的前后台外壳（plugin.php 和 admincp.php）而以直接调用某程序的方式编写插件，因为这样既导致了用户使用不便，代码冗余和不规范，同时又产生了因验证程序考虑不周到而带来的安全隐患。您可以在任何地方，包括链接、表单等处方便的使用上述 URL 地址对插件模块进行调用。<br />
    所有与插件有关的程序，包括全部的前后台程序，因全部使用外壳调用，请务必在第一行加入</p>
<p>    	if(!defined(&#8217;IN_DISCUZ&#8217;)) {<br />
    		exit(&#8217;Access Denied&#8217;);<br />
    	}</p>
<p>    以免其被 URL 直接请求调用，产生安全问题。<br />
    一般情况下，您发布插件请使用插件导出的功能，以方便使用者一次性导入插件的配置数据，极特殊的情况下，也可以分步骤告知使用者如何进行插件配置管理和安装此插件。<br />
    如果功能独立，请尽量使用单独程序的方式编写插件（即外挂型插件），而尽量少的对论坛本身代码进行修改，这将为使用者今后的升级带来很大方便。<br />
    您可以修改 Discuz! 本身的数据结构，但更推荐在不很影响效率的前提下将插件数据用另外的数据表存储，因为不能排除您增加的字段或索引和今后版本 Discuz! 核心数据字段重名的可能。在任何情况下，请不要删除 Discuz! 标准版本数据结构中已有的字段或索引。<br />
    请在插件说明书中对插件做以详尽的描述，例如增加了哪些字段、哪些表，修改了或新增了哪些程序，版本兼容性，后续支持的提供方式（例如不提供支持，或以什么样的方式提供）。如果方便，请尽可能提供插件的卸载方法，例如去除哪些字段、删除哪些新增的程序、将哪些被插件修改的程序恢复原状等等，使用者会感激您为此付出的辛勤劳动，甚至愿意支付相应的费用支持您未来的发展。<br />
    如果插件使用另外的数据表存储，请在插件管理中准确的设置插件所使用的数据表名称（不包含前缀），这样用户在备份数据的时候，能够把插件数据一同备份。<br />
    Discuz! 自 4.0.0 版本起，内置了 8 种自定义积分，存储于 members 表中的 extcredits1 至 extcredits8 字段中，类型为有符号整数，您可以在引用 common.inc.php 后，在 $extcredits 或 $_DCACHE['settings']['extcredits'] 中读取 8 种积分的启用信息（详情请参考 ./forumdata/cache/cache_settings.php）。插件程序中如需更新用户积分，可直接 UPDATE 相应的积分字段，无需其他操作。 </p>
<p>插件钩子的设计</p>
<p>插件钩子的设计，需要您具有一定编程基础，比较了解 Discuz! 论坛程序的结构，并能够使用 PHP 语言撰写代码。对于普通用户，可以略过以下内容。 插件钩子（以下简称“钩子”）属于插件的一部分，因此在设计钩子之前应当首先进入后台－－插件管理，新增插件或者编辑一个现有的插件，即可看到相关设置。</p>
<p>钩子的添加</p>
<p>    钩子名称：在一个插件内，钩子的名称是唯一的，不可重复。名称可以由英文字母、数字和“_”组成，不支持中文，最长255个字符。为了便于理解和记忆钩子的作用， 名称应当尽量简洁清晰，能够表述一定的含义。注意：钩子名称对字母大小敏感，例如：Index_start 和 index_start 将视为两个不同的钩子。<br />
    钩子描述：对钩子的详细说明，如功能介绍、调用方法、使用方法等。<br />
    PHP代码：这里是钩子的核心内容，也是一段PHP代码，需要您自行设计，完成钩子需要处理的数据或者需要执行的操作。<br />
    可用：每个插件允许有多个钩子，您可以自由选择关闭或者开启某个钩子。 </p>
<p>钩子的删除</p>
<p>    在钩子管理界面，您可以随时删除某一个钩子。 钩子删除以后，您应当及时修正放置钩子的程序文件，清除钩子标记，以免影响您论坛的正常使用。</p>
<p>钩子的编辑与升级</p>
<p>    编辑：插件设计阶段，您可能需要随时编辑钩子，每次更改，系统会自动更新缓存文件，您可以立即看到更改的效果。如果是更改钩子名称，那么您可能需要调整钩子放置的程序，修改钩子调用的名称。<br />
    升级：论坛程序进行升级之前，您应当使用插件的导出功能，导出插件备份。论坛升级并正常运行后，再导入插件备份，修改相关程序，重新安放钩子。 </p>
<p>钩子的放置与调用</p>
<p>    钩子设计完成以后，您需要在相应的程序中安放钩子，不同钩子由于作用的不同，放置的位置也是不同的。 安放钩子，您仅仅需要将钩子的调用代码放入即可。调用代码格式如下：</p>
<p>    	 eval($hooks['插件唯一标识符(identifier)_钩子名称']);	  </p>
<p>    例如：调用 插件demo 的钩子 testhook, 我们需要在程序中适当的地方加入下面的代码</p>
<p>    	eval($hooks['demo_testhook']); </p>
<p>设计范例</p>
<p>    此处我们为您提供一个使用钩子技术的插件范例，完成功能十分简单，旨在使您直观的了解钩子的使用。此范例实现了当游客访问论坛首页时，强制用户登录的功能。<br />
        进入系统设置中的插件管理，添加一个名称和惟一标识符均为 demo 的插件。<br />
        编辑插件 demo 详情，找到“插件钩子设置”，添加一个名为 index_force_loggedin 的钩子，然后提交。<br />
        编辑钩子 index_force_loggedin，按如下内容填写设置：<br />
            钩子描述：当游客访问论坛首页的时候，程序会弹出提示框，并自动跳转到登陆页面。<br />
            PHP代码：</p>
<p>            	if(!$discuz_uid) {<br />
            		showmessage(&#8217;请您登陆后访问本站，现在将转入登录页面。&#8217;, &#8216;logging.php?action=login&#8217;);<br />
            	}</p>
<p>        提交后，回到此插件的设置页面。将钩子 index_force_loggedin 设置为可用。<br />
        点击左侧导航，进入插件管理，将插件 demo 设置为可用。<br />
        编辑论坛程序 index.php 安放钩子，方法如下：<br />
            查找代码：</p>
<p>            	$discuz_action = 1;</p>
<p>            在上述代码下放添加代码：</p>
<p>            	eval($hooks['demo_index_alter']);</p>
<p>        保存文件后将文件上传到服务器。<br />
        至此，一个简单的使用钩子实现的插件已经彻底完成。您可以退出登陆并访问论坛首页，测试一下插件的效果。</p>
<p>Discuz! 插件的钩子技术，为广大的插件开发者提供了一个更加灵活的插件设计机制。当 Discuz! 升级后，用户只需重新将钩子调用代码安放到程序中原来的位置，就几乎可以继续使用原来已安装的插件，降低了对于程序修改的幅度和插件安装的难度，更加有利于插件程序的规范、管理、维护、相互交流。因此我们强烈建议插件开发者能够深入研究个应用这一机制，创作出越来越多的优秀插件。 </p>
]]></content:encoded>
			<wfw:commentRss>http://www.result-search.com/m/lyman/233.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Data Validation</title>
		<link>http://www.result-search.com/m/lyman/230.html</link>
		<comments>http://www.result-search.com/m/lyman/230.html#comments</comments>
		<pubDate>Wed, 20 Apr 2011 01:21:47 +0000</pubDate>
		<dc:creator>lyman</dc:creator>
				<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.result-search.com/m/?p=230</guid>
		<description><![CDATA[Untrusted data comes from many sources (users, third party sites, your own database!, &#8230;) and all of it needs to be validated both on input and output.
Contents
[hide]
1 Output Sanitation
1.1 Integers
1.2 HTML/XML
1.2.1 HTML/XML Fragments
1.2.2 Text Nodes
1.2.3 Attribute Nodes
1.2.4 JavaScript
1.3 URLs
1.4 Database
1.5 Filesystem
1.6 HTTP Headers
2 Input Validation
2.1 Slugs
2.2 HTML
2.3 Email
2.4 Arrays
3 Validation Philosophies
3.1 Whitelist
3.2 Blacklist
3.3 Format Detection
3.4 [...]]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Untrusted data comes from many sources (users, third party sites, your own database!, &#8230;) and all of it needs to be validated both on input and output.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Contents</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">[hide]</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">1 Output Sanitation</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">1.1 Integers</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">1.2 HTML/XML</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">1.2.1 HTML/XML Fragments</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">1.2.2 Text Nodes</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">1.2.3 Attribute Nodes</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">1.2.4 JavaScript</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">1.3 URLs</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">1.4 Database</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">1.5 Filesystem</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">1.6 HTTP Headers</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">2 Input Validation</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">2.1 Slugs</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">2.2 HTML</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">2.3 Email</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">2.4 Arrays</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">3 Validation Philosophies</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">3.1 Whitelist</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">3.2 Blacklist</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">3.3 Format Detection</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">3.4 Format Correction</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">4 Changelog</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Output Sanitation</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">The method of data sanitation depends on the type of data and the context in which it is used. Below are some common tasks in WordPress and how they should be sanitized.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Integers</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">intval( $int ) or (int) $int</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">If it&#8217;s supposed to be an integer, cast it as one.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">absint( $int )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Ensures that the result is nonnegative.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">HTML/XML</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Note that many types of XML documents (as opposed to HTML documents) understand only a few named character references: apos, amp, gt, lt, quot. When outputting text to such an XML document, be sure to filter any text containing illegal named entities through WordPress&#8217;s ent2ncr( $text ) function.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">HTML/XML Fragments</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">wp_kses( (string) $fragment, (array) $allowed_html, (array) $protocols = null )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">KSES Strips Evil Scripts. All untrusted HTML (post text, comment text, etc.) should be run through wp_kses().</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">To avoid having to pass an array of allowed HTML tags, you can use wp_kses_post( (string) $fragment ) for tags that are allowed in posts/pages or wp_kses_data( (string) $fragment ) for the small list of tags allowed in comments.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">wp_rel_nofollow( (string) $html )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Adds a &#8220;rel=&#8217;nofollow&#8217;&#8221; attribute to any &lt;a&gt; link.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Text Nodes</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">esc_html( $text ) (since 2.8)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Encodes &lt; &gt; &amp; &#8221; &#8216; (less than, greater than, ampersand, double quote, single quote). Very similar to esc_attr.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">esc_html__ (since 2.8)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Translates and encodes</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">esc_html_e (since 2.8)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Translates, encodes, and echoes</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">esc_textarea (since 3.1)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Encodes text for use inside a textarea element.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) (deprecated since 2.8)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Encodes &lt; &gt; &amp; (less than, greater than, ampersand). Will never double encode entities. Since 2.8, if called with exactly 1 argument, it will encode quote characters as well (via esc_html), as extra protection for older plugins.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">htmlspecialchars( $text, ENT_NOQUOTES )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Encodes &lt; &gt; &amp;. Will double encode html entities if run twice.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Attribute Nodes</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">esc_attr( $text ) (since 2.8)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">attribute_escape( $text ) (deprecated since 2.8)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Encodes &lt; &gt; &amp; &#8221; &#8216; (less than, greater than, ampersand, double quote, single quote). Will never double encode entities. See esc_url() in #URLs</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">esc_attr__</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Translates and encodes</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">esc_attr_e</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Translates, encodes, and echoes</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">htmlspecialchars( $text, ENT_QUOTES )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Encodes &lt; &gt; &amp; &#8221; &#8216;. Will double encode html entities if run twice. See esc_url() in #URLs</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">JavaScript</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">esc_js( $text ) (since 2.8)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">js_escape( $text ) (deprecated since 2.8)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Escapes &#8216;, encodes &#8220;, and fixes line endings.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">URLs</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">esc_url( $url, (array) $protocols = null ) (since 2.8)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Always use esc_url when sanitizing URLs (in text nodes, attribute nodes or anywhere else). Rejects URLs that do not have one of the provided whitelisted protocols (defaulting to http, https, ftp, ftps, mailto, news, irc, gopher, nntp, feed, and telnet), eliminates invalid characters, and removes dangerous characters. Deprecated since 3.0: clean_url()</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">This function encodes characters as HTML entities: use it when generating an (X)HTML or XML document. Encodes ampersands (&amp;) and single quotes (&#8217;) as numeric entity references (&amp;#038, &amp;#039).</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">esc_url_raw( $url, (array) $protocols = null ) (since 2.8)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">For inserting an URL in the database. This function does not encode characters as HTML entities: use it when storing a URL or in other cases where you need the non-encoded URL. This functionality can be replicated in the old clean_url function by setting $context to db.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">urlencode( $scalar )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Encodes for use in URL (as a query parameter, for example)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">urlencode_deep( $array )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">urlencodes all array elements.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Database</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$wpdb-&gt;insert( $table, (array) $data )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$data should be unescaped (the function will escape them for you). Keys are columns, Values are values.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$wpdb-&gt;update( $table, (array) $data, (array) $where )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$data should be unescaped. Keys are columns, Values are values.  $where should be unescaped. Multiple WHERE conditions are ANDed together.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$wpdb-&gt;update(</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&#8216;my_table&#8217;,</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">array( &#8217;status&#8217; =&gt; $untrusted_status, &#8216;title&#8217; =&gt; $untrusted_title ),</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">array( &#8216;id&#8217; =&gt; 123 )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$wpdb-&gt;prepare( $format, (scalar) $value1, (scalar) $value2, &#8230; )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$format is a sprintf() like format string. It only understands %s and %d, neither of which needs to be enclosed in quotation marks.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$wpdb-&gt;get_var( $wpdb-&gt;prepare(</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&#8220;SELECT something FROM table WHERE foo = %s and status = %d&#8221;,</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$name, // an unescaped string (function will do the sanitation for you)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$status // an untrusted integer (function will do the sanitation for you)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">) );</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">esc_sql( $sql ) (since 2.8)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$wpdb-&gt;escape( $text )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Escapes a single string for use in a SQL query. Glorified addslashes().</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$wpdb-&gt;escape_by_ref( &amp;$text )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">No return value.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">like_escape( $string )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Sanitizes $string for use in a LIKE expression of a SQL query. Will still need to be SQL escaped (with one of the above functions).</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Filesystem</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">validate_file( (string) $filename, (array) $allowed_files = &#8220;&#8221; )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Used to prevent directory traversal attacks, or to test a filename against a whitelist. Returns 0 if $filename represents a valid relative path. After validating, you must treat $filename as a relative path (i.e. you must prepend it with an absolute path), since something like /etc/hosts will validate with this function. Returns an integer greater than zero if the given path contains .., ./, or :, or is not in the $allowed_files whitelist. Be careful making boolean interpretations of the result, since false (0) indicates the filename has passed validation, whereas true (&gt; 0) indicates failure.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">HTTP Headers</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Header splitting attacks are annoying since they are dependent on the HTTP client. WordPress has little need to include user generated content in HTTP headers, but when it does, WordPress typically uses whitelisting for most of its HTTP headers.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">WordPress does use user generated content in HTTP Location headers, and provides sanitation for those.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">wp_redirect($location, $status = 302)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">A safe way to redirect to any URL. Ensures the resulting HTTP Location header is legitimate.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">wp_safe_redirect($location, $status = 302)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Even safer. Only allows redirects to whitelisted domains.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Input Validation</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Many of the functions above in #Output_Sanitation are useful for input validation. In addition, WordPress uses the following functions.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Slugs</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">sanitize_title( $title )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Used in post slugs, for example</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">sanitize_user( $username, $strict = false )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Use $strict when creating a new user (though you should use the API for that).</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">HTML</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">balanceTags( $html ) or force_balance_tags( $html )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Tries to make sure HTML tags are balanced so that valid XML is output.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">tag_escape( $html_tag_name )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Sanitizes an HTML tag name (does not escape anything, despite the name of the function).</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Email</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">is_email( $email_address )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">returns boolean false if invalid, or $email_address if valid</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Arrays</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">array_map( &#8216;absint&#8217;, $array )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Ensures all elements are nonnegative integers. Replace callback with whatever is appropriate for your data.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Validation Philosophies</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">There are several different philosophies about how validation should be done. Each is appropriate for different scenarios.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Whitelist</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Accept data only from a finite list of known and trusted values.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$possible_values = array( &#8216;a&#8217;, 1, &#8216;good&#8217; );</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">if ( !in_array( $untrusted, $possible_values ) )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">die( &#8220;Don&#8217;t do that!&#8221; );</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">// Be careful here with fancy breaks and default actions.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">switch ( $untrusted ) {</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">case &#8216;a&#8217; :</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&#8230;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">break;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&#8230;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">default :</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">die( &#8220;You hoser!&#8221; );</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Blacklist</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Reject data from finite list of known untrusted values. This is very rarely a good idea.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Format Detection</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Test to see if the data is of the correct format. Only accept it if it is.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">if ( !ctype_alnum( $data ) )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">die( &#8220;Your data is teh suX0R&#8221; );</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">if ( preg_match( &#8220;/[^0-9.-]/&#8221;, $data ) )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">die( &#8220;Float on somewhere else, jerky&#8221; );</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Format Correction</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Accept most any data, but remove or alter the dangerous pieces.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$trusted_integer = (int) $untrusted_integer;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$trusted_alpha = preg_replace( &#8216;/[^a-z]/i&#8217;, &#8220;&#8221;, $untrusted_alpha );</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$trusted_slug = sanitize_title( $untrusted_slug );</div>
<p><span style="font-family: 'Lucida Grande', Verdana, 'Bitstream Vera Sans', Arial, sans-serif; line-height: 22px;"></p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Untrusted data comes from many sources (users, third party sites, your own database!, &#8230;) and all of it needs to be validated both on input and output.</p>
<p></span></p>
<table id="toc" class="toc" style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 12px; margin-left: 16px; padding-top: 4px; padding-right: 8px; padding-bottom: 4px; padding-left: 8px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f1f1f1; border-top-left-radius: 3px 3px; border-top-right-radius: 3px 3px; border-bottom-right-radius: 3px 3px; border-bottom-left-radius: 3px 3px; float: right; font-size: 10px; max-width: 30%; background-position: initial initial; background-repeat: initial initial; border: 1px solid #dadada;" border="0" summary="Contents">
<tbody style="font-variant: normal !important; text-align: left !important;">
<tr style="font-variant: normal !important; text-align: left !important;">
<td style="font-variant: normal !important; text-align: left !important; padding: 0px; margin: 0px;">
<div id="toctitle" style="font-variant: normal !important; text-align: left !important; font-size: 10px; padding: 0px; margin: 0px;">
<h2 style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 3px; margin-left: 0px; font-style: normal; font-weight: normal; font-family: Georgia, 'Times New Roman', Times, serif; font-size: 18px; color: #333333; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dadada; padding: 0px;">Contents</h2>
<p><span class="toctoggle" style="font-variant: normal !important; text-align: left !important;">[<a id="togglelink" class="internal" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" href="http://codex.wordpress.org/Data_Validation">show</a>]</span></div>
</td>
</tr>
</tbody>
</table>
<p><span style="font-family: 'Lucida Grande', Verdana, 'Bitstream Vera Sans', Arial, sans-serif; line-height: 22px;"><a id="Output_Sanitation" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Output_Sanitation"></a></p>
<h2 style="font-variant: normal !important; text-align: left !important; margin-top: 22px; margin-right: 0px; margin-bottom: 11px; margin-left: 0px; font-style: normal; font-weight: normal; font-family: Georgia, 'Times New Roman', Times, serif; font-size: 23px; color: #333333; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dadada; padding: 0px;"><span class="mw-headline" style="font-variant: normal !important; text-align: left !important;">Output Sanitation</span></h2>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">The method of data sanitation depends on the type of data and the context in which it is used. Below are some common tasks in WordPress and how they should be sanitized.</p>
<p><a id="Integers" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Integers"></a></p>
<h3 style="font-variant: normal !important; text-align: left !important; margin-top: -1px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 18px; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif; border-bottom-width: 1px; border-bottom-style: solid; border-color: #eeeeee;"><span class="mw-headline" style="font-variant: normal !important; text-align: left !important;">Integers</span></h3>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">intval( $int )</code> or <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">(int) $int</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">If it&#8217;s supposed to be an integer, cast it as one.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">absint( $int )</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Ensures that the result is nonnegative.</dd>
</dl>
<p><a id="HTML.2FXML" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="HTML.2FXML"></a></p>
<h3 style="font-variant: normal !important; text-align: left !important; margin-top: -1px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 18px; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif; border-bottom-width: 1px; border-bottom-style: solid; border-color: #eeeeee;"><span class="mw-headline" style="font-variant: normal !important; text-align: left !important;">HTML/XML</span></h3>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Note that many types of XML documents (as opposed to HTML documents) understand only a few named character references: <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">apos, amp, gt, lt, quot</code>. When outputting text to such an XML document, be sure to filter any text containing illegal named entities through WordPress&#8217;s <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">ent2ncr( $text )</code> function.</p>
<p><a id="HTML.2FXML_Fragments" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="HTML.2FXML_Fragments"></a></p>
<h4 style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 18px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 16px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dadada; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif;"><span class="mw-headline" style="font-variant: normal !important; text-align: left !important;">HTML/XML Fragments</span></h4>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Function Reference/wp kses" href="http://codex.wordpress.org/Function_Reference/wp_kses">wp_kses</a>( (string) $fragment, (array) $allowed_html, (array) $protocols = null )</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">KSES Strips Evil Scripts. All untrusted HTML (post text, comment text, etc.) should be run through <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">wp_kses()</code>.</dd>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;"></dd>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">To avoid having to pass an array of allowed HTML tags, you can use <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><a class="new" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: red !important; font-weight: normal;" title="Function Reference/wp kses post (page does not exist)" href="http://codex.wordpress.org/index.php?title=Function_Reference/wp_kses_post&amp;action=edit&amp;redlink=1">wp_kses_post</a>( (string) $fragment )</code> for tags that are allowed in posts/pages or <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><a class="new" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: red !important; font-weight: normal;" title="Function Reference/wp kses data (page does not exist)" href="http://codex.wordpress.org/index.php?title=Function_Reference/wp_kses_data&amp;action=edit&amp;redlink=1">wp_kses_data</a>( (string) $fragment )</code> for the small list of tags allowed in comments.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Function Reference/wp rel nofollow" href="http://codex.wordpress.org/Function_Reference/wp_rel_nofollow">wp_rel_nofollow</a>( (string) $html )</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Adds a &#8220;rel=&#8217;nofollow&#8217;&#8221; attribute to any &lt;a&gt; link.</dd>
</dl>
<p><a id="Text_Nodes" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Text_Nodes"></a></p>
<h4 style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 18px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 16px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dadada; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif;"><span class="mw-headline" style="font-variant: normal !important; text-align: left !important;">Text Nodes</span></h4>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">esc_html( $text )</code> (since 2.8)</dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Encodes <tt style="font-variant: normal !important; text-align: left !important;">&lt; &gt; &amp; " '</tt> (less than, greater than, ampersand, double quote, single quote). Very similar to <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">esc_attr</code>.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">esc_html__</code> (since 2.8)</dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Translates and encodes</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">esc_html_e</code> (since 2.8)</dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Translates, encodes, and echoes</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Function Reference/esc textarea" href="http://codex.wordpress.org/Function_Reference/esc_textarea">esc_textarea</a></code> (since 3.1)</dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Encodes text for use inside a textarea element.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Function Reference/wp specialchars" href="http://codex.wordpress.org/Function_Reference/wp_specialchars">wp_specialchars</a>( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false )</code>(deprecated since 2.8)</dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Encodes <tt style="font-variant: normal !important; text-align: left !important;">&lt; &gt; &amp;</tt> (less than, greater than, ampersand). Will never double encode entities. Since 2.8, if called with exactly 1 argument, it will encode quote characters as well (via <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">esc_html</code>), as extra protection for older plugins.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">htmlspecialchars( $text, ENT_NOQUOTES )</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Encodes <tt style="font-variant: normal !important; text-align: left !important;">&lt; &gt; &amp;</tt>. Will double encode html entities if run twice.</dd>
</dl>
<p><a id="Attribute_Nodes" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Attribute_Nodes"></a></p>
<h4 style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 18px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 16px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dadada; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif;"><span class="mw-headline" style="font-variant: normal !important; text-align: left !important;">Attribute Nodes</span></h4>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Function Reference/esc attr" href="http://codex.wordpress.org/Function_Reference/esc_attr">esc_attr( $text )</a></code> (since 2.8)</dt>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">attribute_escape( $text )</code> (deprecated since 2.8)</dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Encodes <tt style="font-variant: normal !important; text-align: left !important;">&lt; &gt; &amp; " '</tt> (less than, greater than, ampersand, double quote, single quote). Will never double encode entities.<strong style="font-variant: normal !important; text-align: left !important;">See esc_url() in <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" href="http://codex.wordpress.org/Data_Validation#URLs">#URLs</a></strong></dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">esc_attr__</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Translates and encodes</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Function Reference/esc attr e" href="http://codex.wordpress.org/Function_Reference/esc_attr_e">esc_attr_e</a></code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Translates, encodes, and echoes</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">htmlspecialchars( $text, ENT_QUOTES )</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Encodes <tt style="font-variant: normal !important; text-align: left !important;">&lt; &gt; &amp; " '</tt>. Will double encode html entities if run twice. <strong style="font-variant: normal !important; text-align: left !important;">See esc_url() in <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" href="http://codex.wordpress.org/Data_Validation#URLs">#URLs</a></strong></dd>
</dl>
<p><a id="JavaScript" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="JavaScript"></a></p>
<h4 style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 18px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 16px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dadada; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif;"><span class="mw-headline" style="font-variant: normal !important; text-align: left !important;">JavaScript</span></h4>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">esc_js( $text )</code> (since 2.8)</dt>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Function Reference/js escape" href="http://codex.wordpress.org/Function_Reference/js_escape">js_escape</a>( $text )</code> (deprecated since 2.8)</dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Escapes <tt style="font-variant: normal !important; text-align: left !important;">'</tt>, encodes <tt style="font-variant: normal !important; text-align: left !important;">"</tt>, and fixes line endings.</dd>
</dl>
<p><a id="URLs" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="URLs"></a></p>
<h3 style="font-variant: normal !important; text-align: left !important; margin-top: -1px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 18px; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif; border-bottom-width: 1px; border-bottom-style: solid; border-color: #eeeeee;"><span class="mw-headline" style="font-variant: normal !important; text-align: left !important;">URLs</span></h3>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">esc_url( $url, (array) $protocols = null )</code> (since 2.8)</dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Always use <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">esc_url</code> when sanitizing URLs (in text nodes, attribute nodes or anywhere else). Rejects URLs that do not have one of the provided whitelisted protocols (defaulting to <tt style="font-variant: normal !important; text-align: left !important;">http</tt>, <tt style="font-variant: normal !important; text-align: left !important;">https</tt>, <tt style="font-variant: normal !important; text-align: left !important;">ftp</tt>, <tt style="font-variant: normal !important; text-align: left !important;">ftps</tt>, <tt style="font-variant: normal !important; text-align: left !important;">mailto</tt>, <tt style="font-variant: normal !important; text-align: left !important;">news</tt>, <tt style="font-variant: normal !important; text-align: left !important;">irc</tt>, <tt style="font-variant: normal !important; text-align: left !important;">gopher</tt>, <tt style="font-variant: normal !important; text-align: left !important;">nntp</tt>,<tt style="font-variant: normal !important; text-align: left !important;">feed</tt>, and <tt style="font-variant: normal !important; text-align: left !important;">telnet</tt>), eliminates invalid characters, and removes dangerous characters. Deprecated since 3.0: <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">clean_url()</code></dd>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">This function encodes characters as HTML entities: use it when generating an (X)HTML or XML document. Encodes ampersands (<tt style="font-variant: normal !important; text-align: left !important;">&amp;</tt>) and single quotes (<tt style="font-variant: normal !important; text-align: left !important;">'</tt>) as numeric entity references (<tt style="font-variant: normal !important; text-align: left !important;">&amp;#038, &amp;#039</tt>).</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">esc_url_raw( $url, (array) $protocols = null )</code> (since 2.8)</dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">For inserting an URL in the database. This function does not encode characters as HTML entities: use it when storing a URL or in other cases where you need the non-encoded URL. This functionality can be replicated in the old <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">clean_url</code>function by setting <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">$context</code> to <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">db</code>.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">urlencode( $scalar )</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Encodes for use in URL (as a query parameter, for example)</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">urlencode_deep( $array )</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">urlencodes all array elements.</dd>
</dl>
<p><a id="Database" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Database"></a></p>
<h3 style="font-variant: normal !important; text-align: left !important; margin-top: -1px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 18px; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif; border-bottom-width: 1px; border-bottom-style: solid; border-color: #eeeeee;"><span class="mw-headline" style="font-variant: normal !important; text-align: left !important;">Database</span></h3>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Function Reference/wpdb Class" href="http://codex.wordpress.org/Function_Reference/wpdb_Class#INSERT_rows">$wpdb-&gt;insert</a>( $table, (array) $data )</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">$data</code> should be unescaped (the function will escape them for you). Keys are columns, Values are values.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Function Reference/wpdb Class" href="http://codex.wordpress.org/Function_Reference/wpdb_Class#UPDATE_rows">$wpdb-&gt;update</a>( $table, (array) $data, (array) $where )</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">$data</code> should be unescaped. Keys are columns, Values are values. <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">$where</code> should be unescaped. Multiple <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">WHERE</code>conditions are <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">AND</code>ed together.</dd>
</dl>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">$wpdb-&gt;update(
  'my_table',
  array( 'status' =&gt; $untrusted_status, 'title' =&gt; $untrusted_title ),
  array( 'id' =&gt; 123 )
);</pre>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Function Reference/wpdb Class" href="http://codex.wordpress.org/Function_Reference/wpdb_Class#Protect_Queries_Against_SQL_Injection_Attacks">$wpdb-&gt;prepare</a>( $format, (scalar) $value1, (scalar) $value2, ... )</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">$format</code> is a <a class="external text" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="http://php.net/sprintf" href="http://php.net/sprintf">sprintf()</a> like format string. It only understands <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">%s</code> and <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">%d</code>, neither of which needs to be enclosed in quotation marks.</dd>
</dl>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">$wpdb-&gt;get_var( $wpdb-&gt;prepare(
  "SELECT something FROM table WHERE foo = %s and status = %d",
  $name, // an unescaped string (function will do the sanitation for you)
  $status // an untrusted integer (function will do the sanitation for you)
) );</pre>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">esc_sql( $sql )</code> (since 2.8)</dt>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">$wpdb-&gt;escape( $text )</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Escapes a single string for use in a SQL query. Glorified <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">addslashes()</code>.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">$wpdb-&gt;escape_by_ref( &amp;$text )</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">No return value.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">like_escape( $string )</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Sanitizes <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">$string</code> for use in a LIKE expression of a SQL query. Will still need to be SQL escaped (with one of the above functions).</dd>
</dl>
<p><a id="Filesystem" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Filesystem"></a></p>
<h3 style="font-variant: normal !important; text-align: left !important; margin-top: -1px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 18px; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif; border-bottom-width: 1px; border-bottom-style: solid; border-color: #eeeeee;"><span class="mw-headline" style="font-variant: normal !important; text-align: left !important;">Filesystem</span></h3>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">validate_file( (string) $filename, (array) $allowed_files = "" )</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Used to prevent directory traversal attacks, or to test a filename against a whitelist. Returns <tt style="font-variant: normal !important; text-align: left !important;">0</tt> if <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">$filename</code> represents a valid relative path. After validating, you <em style="font-variant: normal !important; text-align: left !important; font-style: italic;">must</em> treat <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">$filename</code> as a relative path (i.e. you must prepend it with an absolute path), since something like <tt style="font-variant: normal !important; text-align: left !important;">/etc/hosts</tt> will validate with this function. Returns an integer greater than zero if the given path contains <tt style="font-variant: normal !important; text-align: left !important;">..</tt>, <tt style="font-variant: normal !important; text-align: left !important;">./</tt>, or <tt style="font-variant: normal !important; text-align: left !important;">:</tt>, or is not in the <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">$allowed_files</code> whitelist. Be careful making boolean interpretations of the result, since <tt style="font-variant: normal !important; text-align: left !important;">false</tt> (0) indicates the filename has passed validation, whereas <tt style="font-variant: normal !important; text-align: left !important;">true</tt> (&gt; 0) indicates failure.</dd>
</dl>
<p><a id="HTTP_Headers" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="HTTP_Headers"></a></p>
<h3 style="font-variant: normal !important; text-align: left !important; margin-top: -1px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 18px; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif; border-bottom-width: 1px; border-bottom-style: solid; border-color: #eeeeee;"><span class="mw-headline" style="font-variant: normal !important; text-align: left !important;">HTTP Headers</span></h3>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Header splitting attacks are annoying since they are dependent on the HTTP client. WordPress has little need to include user generated content in HTTP headers, but when it does, WordPress typically uses <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dfdfdf;" href="http://codex.wordpress.org/Data_Validation#Whitelist">whitelisting</a> for most of its HTTP headers.</p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">WordPress does use user generated content in HTTP Location headers, and provides sanitation for those.</p>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Function Reference/wp redirect" href="http://codex.wordpress.org/Function_Reference/wp_redirect">wp_redirect</a>($location, $status = 302)</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">A safe way to redirect to any URL. Ensures the resulting HTTP Location header is legitimate.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">wp_safe_redirect($location, $status = 302)</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Even safer. Only allows redirects to whitelisted domains.</dd>
</dl>
<p><a id="Input_Validation" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Input_Validation"></a></p>
<h2 style="font-variant: normal !important; text-align: left !important; margin-top: 22px; margin-right: 0px; margin-bottom: 11px; margin-left: 0px; font-style: normal; font-weight: normal; font-family: Georgia, 'Times New Roman', Times, serif; font-size: 23px; color: #333333; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dadada; padding: 0px;"><span class="mw-headline" style="font-variant: normal !important; text-align: left !important;">Input Validation</span></h2>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Many of the functions above in <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dfdfdf;" href="http://codex.wordpress.org/Data_Validation#Output_Sanitation">#Output_Sanitation</a> are useful for input validation. In addition, WordPress uses the following functions.</p>
<p><a id="Slugs" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Slugs"></a></p>
<h3 style="font-variant: normal !important; text-align: left !important; margin-top: -1px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 18px; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif; border-bottom-width: 1px; border-bottom-style: solid; border-color: #eeeeee;"><span class="mw-headline" style="font-variant: normal !important; text-align: left !important;">Slugs</span></h3>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Function Reference/sanitize title" href="http://codex.wordpress.org/Function_Reference/sanitize_title">sanitize_title</a>( $title )</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Used in post slugs, for example</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Function Reference/sanitize user" href="http://codex.wordpress.org/Function_Reference/sanitize_user">sanitize_user</a>( $username, $strict = false )</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Use <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">$strict</code> when creating a new user (though you should use the API for that).</dd>
</dl>
<p><a id="HTML" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="HTML"></a></p>
<h3 style="font-variant: normal !important; text-align: left !important; margin-top: -1px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 18px; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif; border-bottom-width: 1px; border-bottom-style: solid; border-color: #eeeeee;"><span class="mw-headline" style="font-variant: normal !important; text-align: left !important;">HTML</span></h3>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Function Reference/balanceTags" href="http://codex.wordpress.org/Function_Reference/balanceTags">balanceTags</a>( $html )</code> or <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">force_balance_tags( $html )</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Tries to make sure HTML tags are balanced so that valid XML is output.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">tag_escape( $html_tag_name )</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Sanitizes an HTML tag name (does not escape anything, despite the name of the function).</dd>
</dl>
<p><a id="Email" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Email"></a></p>
<h3 style="font-variant: normal !important; text-align: left !important; margin-top: -1px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 18px; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif; border-bottom-width: 1px; border-bottom-style: solid; border-color: #eeeeee;"><span class="mw-headline" style="font-variant: normal !important; text-align: left !important;">Email</span></h3>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Function Reference/is email" href="http://codex.wordpress.org/Function_Reference/is_email">is_email</a>( $email_address )</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">returns boolean false if invalid, or $email_address if valid</dd>
</dl>
<p><a id="Arrays" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Arrays"></a></p>
<h3 style="font-variant: normal !important; text-align: left !important; margin-top: -1px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 18px; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif; border-bottom-width: 1px; border-bottom-style: solid; border-color: #eeeeee;"><span class="mw-headline" style="font-variant: normal !important; text-align: left !important;">Arrays</span></h3>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">array_map( 'absint', $array )</code></dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Ensures all elements are nonnegative integers. Replace callback with whatever is appropriate for your data.</dd>
</dl>
<p><a id="Validation_Philosophies" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Validation_Philosophies"></a></p>
<h2 style="font-variant: normal !important; text-align: left !important; margin-top: 22px; margin-right: 0px; margin-bottom: 11px; margin-left: 0px; font-style: normal; font-weight: normal; font-family: Georgia, 'Times New Roman', Times, serif; font-size: 23px; color: #333333; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dadada; padding: 0px;"><span class="mw-headline" style="font-variant: normal !important; text-align: left !important;">Validation Philosophies</span></h2>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">There are several different philosophies about how validation should be done. Each is appropriate for different scenarios.</p>
<p><a id="Whitelist" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Whitelist"></a></p>
<h3 style="font-variant: normal !important; text-align: left !important; margin-top: -1px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 18px; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif; border-bottom-width: 1px; border-bottom-style: solid; border-color: #eeeeee;"><span class="mw-headline" style="font-variant: normal !important; text-align: left !important;">Whitelist</span></h3>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Accept data only from a finite list of known and trusted values.</p>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">$possible_values = array( 'a', 1, 'good' );
if ( !in_array( $untrusted, $possible_values ) )
  die( "Don't do that!" );</pre>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">// Be careful here with fancy breaks and default actions.
switch ( $untrusted ) {
case 'a' :
  ...
  break;
...
default :
  die( "You hoser!" );
}</pre>
<p><a id="Blacklist" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Blacklist"></a></p>
<h3 style="font-variant: normal !important; text-align: left !important; margin-top: -1px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 18px; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif; border-bottom-width: 1px; border-bottom-style: solid; border-color: #eeeeee;"><span class="mw-headline" style="font-variant: normal !important; text-align: left !important;">Blacklist</span></h3>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Reject data from finite list of known untrusted values. This is very rarely a good idea.</p>
<p><a id="Format_Detection" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Format_Detection"></a></p>
<h3 style="font-variant: normal !important; text-align: left !important; margin-top: -1px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 18px; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif; border-bottom-width: 1px; border-bottom-style: solid; border-color: #eeeeee;"><span class="mw-headline" style="font-variant: normal !important; text-align: left !important;">Format Detection</span></h3>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Test to see if the data is of the correct format. Only accept it if it is.</p>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">if ( !ctype_alnum( $data ) )
  die( "Your data is teh suX0R" );
if ( preg_match( "/[^0-9.-]/", $data ) )
  die( "Float on somewhere else, jerky" );</pre>
<p><a id="Format_Correction" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Format_Correction"></a></p>
<h3 style="font-variant: normal !important; text-align: left !important; margin-top: -1px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 18px; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif; border-bottom-width: 1px; border-bottom-style: solid; border-color: #eeeeee;"><span class="mw-headline" style="font-variant: normal !important; text-align: left !important;">Format Correction</span></h3>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Accept most any data, but remove or alter the dangerous pieces.</p>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">$trusted_integer = (int) $untrusted_integer;
$trusted_alpha = preg_replace( '/[^a-z]/i', "", $untrusted_alpha );
$trusted_slug = sanitize_title( $untrusted_slug );</pre>
<p></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.result-search.com/m/lyman/230.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Function Reference/wpdb Class</title>
		<link>http://www.result-search.com/m/lyman/227.html</link>
		<comments>http://www.result-search.com/m/lyman/227.html#comments</comments>
		<pubDate>Wed, 20 Apr 2011 01:18:57 +0000</pubDate>
		<dc:creator>lyman</dc:creator>
				<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.result-search.com/m/?p=227</guid>
		<description><![CDATA[Interfacing With the Database
WordPress provides a class of functions for all database manipulations. The class is called wpdb and is loosely based on the ezSQL class written and maintained by Justin Vincent.

Notes On Use
Methods in the wpdb class should not be called directly. WordPress provides a global variable $wpdb, which is an instantiation of the class already set up to [...]]]></description>
			<content:encoded><![CDATA[<h2 style="font-variant: normal !important; text-align: left !important; margin-top: 22px; margin-right: 0px; margin-bottom: 11px; margin-left: 0px; font-style: normal; font-weight: normal; font-family: Georgia, 'Times New Roman', Times, serif; font-size: 23px; color: #333333; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dadada; padding: 0px;"><span style="font-variant: normal !important; text-align: left !important;">Interfacing With the Database</span></h2>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">WordPress provides a class of functions for all database manipulations. The class is called <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">wpdb</code> and is loosely based on the <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dfdfdf;" title="http://justinvincent.com/ezsql" href="http://justinvincent.com/ezsql">ezSQL</a> class written and maintained by <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dfdfdf;" title="http://www.jvmultimedia.com" href="http://www.jvmultimedia.com/">Justin Vincent</a>.</p>
<p><a id="Notes_On_Use" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Notes_On_Use"></a></p>
<h3 style="font-variant: normal !important; text-align: left !important; margin-top: -1px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 18px; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif; border-bottom-width: 1px; border-bottom-style: solid; border-color: #eeeeee;"><span style="font-variant: normal !important; text-align: left !important;">Notes On Use</span></h3>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Methods in the <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">wpdb</code> class should not be called directly. WordPress provides a global variable <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">$wpdb</code>, which is an instantiation of the class already set up to talk to the WordPress database. Always use the global <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">$wpdb</code> variable. (Remember to <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dfdfdf;" title="http://www.php.net/manual/en/language.variables.scope.php#language.variables.scope.global" href="http://www.php.net/manual/en/language.variables.scope.php#language.variables.scope.global">globalize</a> <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">$wpdb</code> before using it in any custom functions.)</p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">The <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">$wpdb</code> object can be used to read data from any table in the WordPress database, not just the standard tables that WordPress creates. For example to SELECT some information from a custom table called &#8220;mytable&#8221;, you can do the following. <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"> </code></p>
<p><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"></p>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">$myrows = $wpdb-&gt;<a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" href="http://codex.wordpress.org/Function_Reference/wpdb_Class#SELECT_Generic_Results">get_results</a>( "SELECT id, name FROM mytable" );</pre>
<p></code></p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">The <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">$wpdb</code> object can talk to any number of tables, but only one database: the WordPress database. In the rare case you need to connect to another database, you will have to instantiate your own object from the <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">wpdb</code> class with the appropriate connection details. For extremely complicated setups with many databases, consider using <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dfdfdf;" title="http://wordpress.org/extend/plugins/hyperdb/" href="http://wordpress.org/extend/plugins/hyperdb/">hyperdb</a> instead.</p>
<p><a id="Run_Any_Query_on_the_Database" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Run_Any_Query_on_the_Database"></a></p>
<h2 style="font-variant: normal !important; text-align: left !important; margin-top: 22px; margin-right: 0px; margin-bottom: 11px; margin-left: 0px; font-style: normal; font-weight: normal; font-family: Georgia, 'Times New Roman', Times, serif; font-size: 23px; color: #333333; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dadada; padding: 0px;"><span style="font-variant: normal !important; text-align: left !important;">Run Any Query on the Database</span></h2>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">The <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">query</code> function allows you to execute <em style="font-variant: normal !important; text-align: left !important;">any</em> SQL query on the WordPress database. It is best to use a more specific function (see below), however, for SELECT queries.</p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><span style="font-variant: normal !important; text-align: left !important; color: #000000;"> <span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">&lt;?php $wpdb</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">-&gt;</span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">query</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">(</span><span style="font-variant: normal !important; text-align: left !important; color: #dd0000;">'query'</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">); </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">?&gt;</span> </span> </code></p>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">query </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">(string) The SQL query you wish to execute.</dd>
</dl>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">The function returns an integer corresponding to the number of rows affected/selected. If there is a MySQL error, the function will return <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">FALSE</code>. (<strong style="font-variant: normal !important; text-align: left !important;">Note</strong>: since both 0 and FALSE can be returned, make sure you use the correct comparison operator: equality <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">==</code> vs. identicality <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">===</code>).</p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Note: As with all functions in this class that execute SQL queries, you must SQL escape all inputs (e.g., <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">wpdb-&gt;escape($user_entered_data_string)</code>). See the section entitled <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dfdfdf;" title="http://codex.wordpress.org/wpdb_Class#Protect_Queries_Against_SQL_Injection_Attacks" href="http://codex.wordpress.org/wpdb_Class#Protect_Queries_Against_SQL_Injection_Attacks">Protect Queries Against SQL Injection Attacks</a> below.</p>
<p><a id="Examples" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Examples"></a></p>
<h3 style="font-variant: normal !important; text-align: left !important; margin-top: -1px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 18px; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif; border-bottom-width: 1px; border-bottom-style: solid; border-color: #eeeeee;"><span style="font-variant: normal !important; text-align: left !important;">Examples</span></h3>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Delete the &#8216;gargle&#8217; meta key and value from Post 13.</p>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">$wpdb-&gt;query("
	DELETE FROM $wpdb-&gt;postmeta WHERE post_id = '13'
	AND meta_key = 'gargle'");</pre>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;"><em style="font-variant: normal !important; text-align: left !important;">Performed in WordPress by <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dfdfdf;" title="Function Reference/delete post meta" href="http://codex.wordpress.org/Function_Reference/delete_post_meta">delete_post_meta()</a></code>.</em></p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;"><br style="font-variant: normal !important; text-align: left !important;" />Set the parent of <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dfdfdf;" title="Pages" href="http://codex.wordpress.org/Pages">Page</a> 15 to Page 7.</p>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">$wpdb-&gt;query("
	UPDATE $wpdb-&gt;posts SET post_parent = 7
	WHERE ID = 15 AND post_status = 'static'");</pre>
<p><a id="SELECT_a_Variable" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="SELECT_a_Variable"></a></p>
<h2 style="font-variant: normal !important; text-align: left !important; margin-top: 22px; margin-right: 0px; margin-bottom: 11px; margin-left: 0px; font-style: normal; font-weight: normal; font-family: Georgia, 'Times New Roman', Times, serif; font-size: 23px; color: #333333; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dadada; padding: 0px;"><span style="font-variant: normal !important; text-align: left !important;">SELECT a Variable</span></h2>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">The <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">get_var</code> function returns a single variable from the database. Though only one variable is returned, the entire result of the query is cached for later use. Returns <tt style="font-variant: normal !important; text-align: left !important;">NULL</tt> if no result is found.</p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><span style="font-variant: normal !important; text-align: left !important; color: #000000;"> <span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">&lt;?php $wpdb</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">-&gt;</span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">get_var</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">(</span><span style="font-variant: normal !important; text-align: left !important; color: #dd0000;">'query'</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">,</span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">column_offset</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">,</span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">row_offset</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">); </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">?&gt;</span> </span> </code></p>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">query </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">(string) The query you wish to run. Setting this parameter to <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">null</code> will return the specified variable from the cached results of the previous query.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">column_offset </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">(integer) The desired column (<strong style="font-variant: normal !important; text-align: left !important;">0</strong> being the first). Defaults to <strong style="font-variant: normal !important; text-align: left !important;">0</strong>.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">row_offset </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">(integer) The desired row (<strong style="font-variant: normal !important; text-align: left !important;">0</strong> being the first). Defaults to <strong style="font-variant: normal !important; text-align: left !important;">0</strong>.</dd>
</dl>
<p><a id="Examples_2" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Examples_2"></a></p>
<h3 style="font-variant: normal !important; text-align: left !important; margin-top: -1px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 18px; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif; border-bottom-width: 1px; border-bottom-style: solid; border-color: #eeeeee;"><span style="font-variant: normal !important; text-align: left !important;">Examples</span></h3>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Retrieve and display the number of users.</p>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">&lt;?php
$user_count = $wpdb-&gt;get_var($wpdb-&gt;prepare("SELECT COUNT(*) FROM $wpdb-&gt;users;"));
echo '&lt;p&gt;User count is ' . $user_count . '&lt;/p&gt;';
?&gt;</pre>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Retrieve and display the sum of a <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dfdfdf;" title="Custom Fields" href="http://codex.wordpress.org/Custom_Fields">Custom Field value</a>.</p>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">&lt;?php
$meta_key = 'miles';//set this to appropriate custom field meta key
$allmiles=$wpdb-&gt;get_var($wpdb-&gt;prepare("SELECT sum(meta_value) FROM $wpdb-&gt;postmeta WHERE meta_key = %s", $meta_key));
echo '&lt;p&gt;Total miles is '.$allmiles . '&lt;/p&gt;';
?&gt;</pre>
<p><a id="SELECT_a_Row" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="SELECT_a_Row"></a></p>
<h2 style="font-variant: normal !important; text-align: left !important; margin-top: 22px; margin-right: 0px; margin-bottom: 11px; margin-left: 0px; font-style: normal; font-weight: normal; font-family: Georgia, 'Times New Roman', Times, serif; font-size: 23px; color: #333333; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dadada; padding: 0px;"><span style="font-variant: normal !important; text-align: left !important;">SELECT a Row</span></h2>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">To retrieve an entire row from a query, use <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">get_row</code>. The function can return the row as an object, an associative array, or as a numerically indexed array. If more than one row is returned by the query, only the specified row is returned by the function, but all rows are cached for later use. Returns NULL if no result is found.</p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><span style="font-variant: normal !important; text-align: left !important; color: #000000;"> <span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">&lt;?php $wpdb</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">-&gt;</span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">get_row</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">(</span><span style="font-variant: normal !important; text-align: left !important; color: #dd0000;">'query'</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">, </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">output_type</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">, </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">row_offset</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">); </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">?&gt;</span> </span> </code></p>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">query </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">(string) The query you wish to run.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">output_type </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">One of three pre-defined constants. Defaults to OBJECT.</p>
<ul style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 16px; list-style-type: square; list-style-position: initial; list-style-image: initial; padding: 0px;">
<li style="font-variant: normal !important; text-align: left !important; padding: 0px; margin: 0px;">OBJECT &#8211; result will be output as an object.</li>
<li style="font-variant: normal !important; text-align: left !important; padding: 0px; margin: 0px;">ARRAY_A &#8211; result will be output as an associative array.</li>
<li style="font-variant: normal !important; text-align: left !important; padding: 0px; margin: 0px;">ARRAY_N &#8211; result will be output as a numerically indexed array.</li>
</ul>
</dd>
</dl>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">row_offset </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">(integer) The desired row (<strong style="font-variant: normal !important; text-align: left !important;">0</strong> being the first). Defaults to <strong style="font-variant: normal !important; text-align: left !important;">0</strong>.</dd>
</dl>
<p><a id="Examples_3" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Examples_3"></a></p>
<h3 style="font-variant: normal !important; text-align: left !important; margin-top: -1px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 18px; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif; border-bottom-width: 1px; border-bottom-style: solid; border-color: #eeeeee;"><span style="font-variant: normal !important; text-align: left !important;">Examples</span></h3>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Get all the information about Link 10.</p>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">$mylink = $wpdb-&gt;get_row("SELECT * FROM $wpdb-&gt;links WHERE link_id = 10");</pre>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">The properties of the <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">$mylink</code> object are the column names of the result from the SQL query (in this all of the columns from the <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">$wpdb-&gt;links</code> table).</p>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">echo $mylink-&gt;link_id; // prints "10"</pre>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;"><br style="font-variant: normal !important; text-align: left !important;" />In contrast, using</p>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">$mylink = $wpdb-&gt;get_row("SELECT * FROM $wpdb-&gt;links WHERE link_id = 10", ARRAY_A);</pre>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">would result in an associative array:</p>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">echo $mylink['link_id']; // prints "10"</pre>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;"><br style="font-variant: normal !important; text-align: left !important;" />and</p>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">$mylink = $wpdb-&gt;get_row("SELECT * FROM $wpdb-&gt;links WHERE link_id = 10", ARRAY_N);</pre>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">would result in a numerically indexed array:</p>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">echo $mylink[1]; // prints "10"</pre>
<p><a id="SELECT_a_Column" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="SELECT_a_Column"></a></p>
<h2 style="font-variant: normal !important; text-align: left !important; margin-top: 22px; margin-right: 0px; margin-bottom: 11px; margin-left: 0px; font-style: normal; font-weight: normal; font-family: Georgia, 'Times New Roman', Times, serif; font-size: 23px; color: #333333; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dadada; padding: 0px;"><span style="font-variant: normal !important; text-align: left !important;">SELECT a Column</span></h2>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">To SELECT a column, use <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">get_col</code>. This function outputs a dimensional array. If more than one column is returned by the query, only the specified column will be returned by the function, but the entire result is cached for later use. Returns an empty array if no result is found.</p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><span style="font-variant: normal !important; text-align: left !important; color: #000000;"> <span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">&lt;?php $wpdb</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">-&gt;</span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">get_col</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">(</span><span style="font-variant: normal !important; text-align: left !important; color: #dd0000;">'query'</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">,</span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">column_offset</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">); </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">?&gt;</span> </span> </code></p>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">query </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">(string) the query you wish to execute. Setting this parameter to <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">null</code> will return the specified column from the cached results of the previous query.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">column_offset </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">(integer) The desired column (<strong style="font-variant: normal !important; text-align: left !important;">0</strong> being the first). Defaults to <strong style="font-variant: normal !important; text-align: left !important;">0</strong>.</dd>
</dl>
<p><a id="Examples_4" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Examples_4"></a></p>
<h3 style="font-variant: normal !important; text-align: left !important; margin-top: -1px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 18px; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif; border-bottom-width: 1px; border-bottom-style: solid; border-color: #eeeeee;"><span style="font-variant: normal !important; text-align: left !important;">Examples</span></h3>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">For this example, assume the blog is devoted to information about automobiles. Each post describes a particular car (e.g. 1969 Ford Mustang), and three <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dfdfdf;" title="Custom Fields" href="http://codex.wordpress.org/Custom_Fields">Custom Fields</a>, manufacturer, model, and year, are assigned to each post. This example will display the post titles, filtered by a particular manufacturer (Ford), and sorted by model and year.</p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">The <strong style="font-variant: normal !important; text-align: left !important;">get_col</strong> form of the <tt style="font-variant: normal !important; text-align: left !important;">wpdb Class</tt> is used to return an array of all the post ids meeting the criteria and sorted in the correct order. Then a <em style="font-variant: normal !important; text-align: left !important;">foreach</em> construct is used to iterate through that array of post ids, displaying the title of each post. Note that the SQL for this example was created by <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dfdfdf;" title="http://stackoverflow.com/questions/1690762/complicated-mysql-query/1690808#1690808" href="http://stackoverflow.com/questions/1690762/complicated-mysql-query/1690808#1690808">Andomar</a>.</p>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">&lt;?php
$meta_key1 = 'model';
$meta_key2 = 'year';
$meta_key3 = 'manufacturer';
$meta_key3_value = 'Ford';

$postids=$wpdb-&gt;get_col($wpdb-&gt;prepare("
SELECT      key3.post_id
FROM        $wpdb-&gt;postmeta key3
INNER JOIN  $wpdb-&gt;postmeta key1
            on key1.post_id = key3.post_id
            and key1.meta_key = %s
INNER JOIN  $wpdb-&gt;postmeta key2
            on key2.post_id = key3.post_id
            and key2.meta_key = %s
WHERE       key3.meta_key = %s
            and key3.meta_value = %s
ORDER BY    key1.meta_value, key2.meta_value",$meta_key1, $meta_key2, $meta_key3, $meta_key3_value)); 

if ($postids) {
  echo 'List of ' . $meta_key3_value . '(s), sorted by ' . $meta_key1 . ', ' . $meta_key2;
  foreach ($postids as $id) {
    $post=get_post(intval($id));
    setup_postdata($post);?&gt;
    &lt;p&gt;&lt;a href="&lt;?php the_permalink() ?&gt;" rel="bookmark" title="Permanent Link to &lt;?php the_title_attribute(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/p&gt;
    &lt;?php
  }
}
?&gt;</pre>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">This example lists all posts that contain a particular custom field, but sorted by the value of a second custom field.</p>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">&lt;?php
//List all posts with custom field Color, sorted by the value of custom field Display_Order
//does not exclude any 'post_type'
//assumes each post has just one custom field for Color, and one for Display_Order
$meta_key1 = 'Color';
$meta_key2 = 'Display_Order';

$postids=$wpdb-&gt;get_col($wpdb-&gt;prepare("
SELECT      key1.post_id
FROM        $wpdb-&gt;postmeta key1
INNER JOIN  $wpdb-&gt;postmeta key2
            on key2.post_id = key1.post_id
            and key2.meta_key = %s
WHERE       key1.meta_key = %s
ORDER BY    key2.meta_value+(0) ASC",
         $meta_key2,$meta_key1)); 

if ($postids) {
  echo 'List of '. $meta_key1  . ' posts, sorted by ' . $meta_key2 ;
  foreach ($postids as $id) {
    $post=get_post(intval($id));
    setup_postdata($post);?&gt;
    &lt;p&gt;&lt;a href="&lt;?php the_permalink() ?&gt;" rel="bookmark" title="Permanent Link to &lt;?php the_title_attribute(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/p&gt;
    &lt;?php
  }
}
?&gt;</pre>
<p><a id="SELECT_Generic_Results" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="SELECT_Generic_Results"></a></p>
<h2 style="font-variant: normal !important; text-align: left !important; margin-top: 22px; margin-right: 0px; margin-bottom: 11px; margin-left: 0px; font-style: normal; font-weight: normal; font-family: Georgia, 'Times New Roman', Times, serif; font-size: 23px; color: #333333; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dadada; padding: 0px;"><span style="font-variant: normal !important; text-align: left !important;">SELECT Generic Results</span></h2>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Generic, mulitple row results can be pulled from the database with <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">get_results</code>. The function returns the entire query result as an array. Each element of this array corresponds to one row of the query result and, like <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">get_row</code>, can be an object, an associative array, or a numbered array.</p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><span style="font-variant: normal !important; text-align: left !important; color: #000000;"> <span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">&lt;?php $wpdb</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">-&gt;</span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">get_results</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">(</span><span style="font-variant: normal !important; text-align: left !important; color: #dd0000;">'query'</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">, </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">output_type</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">); </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">?&gt;</span> </span> </code></p>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">query </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">(string) The query you wish to run. Setting this parameter to <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">null</code> will return the data from the cached results of the previous query.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">output_type </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">One of four pre-defined constants. Defaults to OBJECT. See <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" href="http://codex.wordpress.org/Function_Reference/wpdb_Class#SELECT_a_Row">SELECT a Row</a> and its examples for more information.</p>
<ul style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 16px; list-style-type: square; list-style-position: initial; list-style-image: initial; padding: 0px;">
<li style="font-variant: normal !important; text-align: left !important; padding: 0px; margin: 0px;">OBJECT &#8211; result will be output as a numerically indexed array of row objects.</li>
<li style="font-variant: normal !important; text-align: left !important; padding: 0px; margin: 0px;">OBJECT_K &#8211; result will be output as an associative array of row objects, using first column&#8217;s values as keys (duplicates will be discarded).</li>
<li style="font-variant: normal !important; text-align: left !important; padding: 0px; margin: 0px;">ARRAY_A &#8211; result will be output as an numerically indexed array of associative arrays, using column names as keys.</li>
<li style="font-variant: normal !important; text-align: left !important; padding: 0px; margin: 0px;">ARRAY_N &#8211; result will be output as a numerically indexed array of numerically indexed arrays.</li>
</ul>
</dd>
</dl>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Since this function uses the &#8216;$wpdb-&gt;query()&#8217; function all the class variables are properly set. The results count for a &#8216;SELECT&#8217; query will be stored in $wpdb-&gt;num_rows.</p>
<p><a id="Examples_5" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Examples_5"></a></p>
<h3 style="font-variant: normal !important; text-align: left !important; margin-top: -1px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 18px; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif; border-bottom-width: 1px; border-bottom-style: solid; border-color: #eeeeee;"><span style="font-variant: normal !important; text-align: left !important;">Examples</span></h3>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Get the IDs and Titles of all the Drafts by User 5 and echo the Titles.</p>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">$fivesdrafts = $wpdb-&gt;get_results("SELECT ID, post_title FROM $wpdb-&gt;posts
	WHERE post_status = 'draft' AND post_author = 5");

foreach ($fivesdrafts as $fivesdraft) {
	echo $fivesdraft-&gt;post_title;
}</pre>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Get all information on the Drafts by User 5.</p>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">&lt;?php
$fivesdrafts = $wpdb-&gt;get_results("SELECT * FROM $wpdb-&gt;posts
	WHERE post_status = 'draft' AND post_author = 5");
if ($fivesdrafts) :
	foreach ($fivesdrafts as $post) :
		setup_postdata($post);
?&gt;
	&lt;h2&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;" rel="bookmark"
		title="Permanent Link to &lt;?php the_title(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;?php
	endforeach;
else :
?&gt;
    &lt;h2&gt; Not Found&lt;/h2&gt;
&lt;?php endif; ?&gt;</pre>
<p><a id="INSERT_rows" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="INSERT_rows"></a></p>
<h2 style="font-variant: normal !important; text-align: left !important; margin-top: 22px; margin-right: 0px; margin-bottom: 11px; margin-left: 0px; font-style: normal; font-weight: normal; font-family: Georgia, 'Times New Roman', Times, serif; font-size: 23px; color: #333333; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dadada; padding: 0px;"><span style="font-variant: normal !important; text-align: left !important;">INSERT rows</span></h2>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Insert a row into a table.</p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><span style="font-variant: normal !important; text-align: left !important; color: #000000;"> <span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">&lt;?php $wpdb</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">-&gt;</span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">insert</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">( </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">$table</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">, </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">$data</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">, </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">$format </span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">); </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">?&gt;</span> </span> </code></p>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">table </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">(string) The name of the table to insert data into.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">data </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">(array) Data to insert (in column =&gt; value pairs). Both $data columns and $data values should be &#8220;raw&#8221; (neither should be SQL escaped).</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">format </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">(array|string) (optional) An array of formats to be mapped to each of the value in $data. If string, that format will be used for all of the values in $data. If omitted, all values in $data will be treated as strings unless otherwise specified in wpdb::$field_types.</dd>
</dl>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Possible format values: %s as string; %d as decimal number; and %f as float.</p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">After insert, the ID generated for the AUTO_INCREMENT column can be accessed with:</p>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">$wpdb-&gt;insert_id</pre>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">This function returns false if the row could not be inserted.</p>
<p><a id="Examples_6" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Examples_6"></a></p>
<h3 style="font-variant: normal !important; text-align: left !important; margin-top: -1px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 18px; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif; border-bottom-width: 1px; border-bottom-style: solid; border-color: #eeeeee;"><span style="font-variant: normal !important; text-align: left !important;">Examples</span></h3>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Insert two columns in a row, the first value being a string and the second a number:</p>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">$wpdb-&gt;insert( 'table', array( 'column1' =&gt; 'value1', 'column2' =&gt; 123 ), array( '%s', '%d' ) )</pre>
<p><a id="UPDATE_rows" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="UPDATE_rows"></a></p>
<h2 style="font-variant: normal !important; text-align: left !important; margin-top: 22px; margin-right: 0px; margin-bottom: 11px; margin-left: 0px; font-style: normal; font-weight: normal; font-family: Georgia, 'Times New Roman', Times, serif; font-size: 23px; color: #333333; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dadada; padding: 0px;"><span style="font-variant: normal !important; text-align: left !important;">UPDATE rows</span></h2>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Update a row in the table.</p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><span style="font-variant: normal !important; text-align: left !important; color: #000000;"> <span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">&lt;?php $wpdb</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">-&gt;</span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">update</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">( </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">$table</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">, </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">$data</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">, </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">$where</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">, </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">$format </span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">= </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">null</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">, </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">$where_format </span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">= </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">null </span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">); </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">?&gt;</span> </span> </code></p>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">table </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">(string) The name of the table to update.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">data </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">(array) Data to update (in column =&gt; value pairs). Both $data columns and $data values should be &#8220;raw&#8221; (neither should be SQL escaped).</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">where </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">(array) A named array of WHERE clauses (in column =&gt; value pairs). Multiple clauses will be joined with ANDs. Both $where columns and $where values should be &#8220;raw&#8221;.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">format </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">(array|string) (optional) An array of formats to be mapped to each of the values in $data. If string, that format will be used for all of the values in $data.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">where_format </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">(array|string) (optional) An array of formats to be mapped to each of the values in $where. If string, that format will be used for all of the items in $where.</dd>
</dl>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;"><strong style="font-variant: normal !important; text-align: left !important; font-weight: bold;">Possible format values</strong>: %s as string; %d as decimal number and %f as float. If omitted, all values in $where will be treated as strings.</p>
<p><a id="Examples_7" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Examples_7"></a></p>
<h3 style="font-variant: normal !important; text-align: left !important; margin-top: -1px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 18px; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif; border-bottom-width: 1px; border-bottom-style: solid; border-color: #eeeeee;"><span style="font-variant: normal !important; text-align: left !important;">Examples</span></h3>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Update a row, where the ID is 1, the value in the first column is a string and the value in the second column is a number:</p>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">$wpdb-&gt;update( 'table', array( 'column1' =&gt; 'value1', 'column2' =&gt; 'value2' ), array( 'ID' =&gt; 1 ), array( '%s', '%d' ), array( '%d' ) )</pre>
<p><a id="Protect_Queries_Against_SQL_Injection_Attacks" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Protect_Queries_Against_SQL_Injection_Attacks"></a></p>
<h2 style="font-variant: normal !important; text-align: left !important; margin-top: 22px; margin-right: 0px; margin-bottom: 11px; margin-left: 0px; font-style: normal; font-weight: normal; font-family: Georgia, 'Times New Roman', Times, serif; font-size: 23px; color: #333333; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dadada; padding: 0px;"><span style="font-variant: normal !important; text-align: left !important;">Protect Queries Against SQL Injection Attacks</span></h2>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">For a more complete overview of SQL escaping in WordPress, see <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dfdfdf;" title="Data Validation" href="http://codex.wordpress.org/Data_Validation#Database">database Data Validation</a>. That <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dfdfdf;" title="Data Validation" href="http://codex.wordpress.org/Data_Validation">Data Validation</a> article is a <strong style="font-variant: normal !important; text-align: left !important;">must-read</strong> for all WordPress code contributors and plugin authors.</p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Briefly, though, all data in SQL queries must be SQL-escaped before the SQL query is executed to prevent against SQL injection attacks. This can be conveniently done with the <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">prepare</code> method, which supports both a <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dfdfdf;" title="http://php.net/sprintf" href="http://php.net/sprintf">sprintf()</a>-like and<a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dfdfdf;" title="http://php.net/vsprintf" href="http://php.net/vsprintf">vsprintf()</a>-like syntax.</p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><span style="font-variant: normal !important; text-align: left !important; color: #000000;"> <span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">&lt;?php $sql </span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">= </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">$wpdb</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">-&gt;</span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">prepare</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">( </span><span style="font-variant: normal !important; text-align: left !important; color: #dd0000;">'query' </span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">[, </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">value_parameter</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">, </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">value_parameter </span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">... ] ); </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">?&gt;</span> </span> </code></p>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">query </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">(string) The SQL query you wish to execute, with <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">%s</code> and <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">%d</code> placeholders. Any other <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">%</code> characters may cause parsing errors unless they are escaped. All <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">%</code> characters inside SQL string literals, including LIKE wildcards, must be double-% escaped as <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">%%</code>.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">value_parameter </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">(int|string|array) The value to substitute into the placeholder. Many values may be passed by simply passing more arguments in a <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="http://php.net/sprintf" href="http://php.net/sprintf">sprintf()</a>-like fashion. Alternatively the second argument can be an array containing the values as in PHP&#8217;s <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="http://php.net/vsprintf" href="http://php.net/vsprintf">vsprintf()</a> function. Care must be taken not to allow direct user input to this parameter, which would enable array manipulation of any query with multiple placeholders. Values must not already be SQL-escaped.</dd>
</dl>
<p><a id="Examples_8" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Examples_8"></a></p>
<h3 style="font-variant: normal !important; text-align: left !important; margin-top: -1px; margin-right: 0px; margin-bottom: 4px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; font-style: normal; font-weight: normal; font-size: 18px; color: #333333; font-family: Georgia, 'Times New Roman', Times, serif; border-bottom-width: 1px; border-bottom-style: solid; border-color: #eeeeee;"><span style="font-variant: normal !important; text-align: left !important;">Examples</span></h3>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Add Meta key =&gt; value pair &#8220;Harriet&#8217;s Adages&#8221; =&gt; &#8220;WordPress&#8217; database interface is like Sunday Morning: Easy.&#8221; to Post 10.</p>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">$metakey = "Harriet's Adages";
$metavalue = "WordPress' database interface is like Sunday Morning: Easy.";

$wpdb-&gt;query( $wpdb-&gt;prepare( "
	INSERT INTO $wpdb-&gt;postmeta
	( post_id, meta_key, meta_value )
	VALUES ( %d, %s, %s )",
        10, $metakey, $metavalue ) );</pre>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;"><em style="font-variant: normal !important; text-align: left !important;">Performed in WordPress by <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">add_meta()</code>.</em></p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">The same query using <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dfdfdf;" title="http://php.net/vsprintf" href="http://php.net/vsprintf">vsprintf()</a>-like syntax.</p>
<pre style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; font-size: 12px; line-height: 1.3em; overflow-x: auto; overflow-y: auto; color: #000000; font-weight: inherit; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 11px; border: 1px solid #dadada;">$metakey = "Harriet's Adages";
$metavalue = "WordPress' database interface is like Sunday Morning: Easy.";

$wpdb-&gt;query( $wpdb-&gt;prepare( "
	INSERT INTO $wpdb-&gt;postmeta
	( post_id, meta_key, meta_value )
	VALUES ( %d, %s, %s )",
        array(10, $metakey, $metavalue) ) );</pre>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;"><em style="font-variant: normal !important; text-align: left !important;">Note that in this example we pack the values together in an array. This can be useful when we don&#8217;t know the number of arguments we need to pass until runtime.</em></p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">Notice that you do not have to worry about quoting strings. Instead of passing the variables directly into the SQL query, use a <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">%s</code> placeholder for strings and a <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">%d</code> placedolder for integers. You can pass as many values as you like, each as a new parameter in the <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">prepare()</code> method.</p>
<p><a id="Show_and_Hide_SQL_Errors" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Show_and_Hide_SQL_Errors"></a></p>
<h2 style="font-variant: normal !important; text-align: left !important; margin-top: 22px; margin-right: 0px; margin-bottom: 11px; margin-left: 0px; font-style: normal; font-weight: normal; font-family: Georgia, 'Times New Roman', Times, serif; font-size: 23px; color: #333333; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dadada; padding: 0px;"><span style="font-variant: normal !important; text-align: left !important;">Show and Hide SQL Errors</span></h2>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">You can turn error echoing on and off with the <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">show_errors</code> and <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">hide_errors</code>, respectively.</p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><span style="font-variant: normal !important; text-align: left !important; color: #000000;"> <span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">&lt;?php $wpdb</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">-&gt;</span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">show_errors</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">(); </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">?&gt;</span> <br style="font-variant: normal !important; text-align: left !important;" /> <span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">&lt;?php $wpdb</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">-&gt;</span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">hide_errors</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">(); </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">?&gt;</span> </span> </code></p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">You can also print the error (if any) generated by the most recent query with <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">print_error</code>.</p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><span style="font-variant: normal !important; text-align: left !important; color: #000000;"> <span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">&lt;?php $wpdb</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">-&gt;</span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">print_error</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">(); </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">?&gt;</span> </span> </code></p>
<p><a id="Getting_Column_Information" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Getting_Column_Information"></a></p>
<h2 style="font-variant: normal !important; text-align: left !important; margin-top: 22px; margin-right: 0px; margin-bottom: 11px; margin-left: 0px; font-style: normal; font-weight: normal; font-family: Georgia, 'Times New Roman', Times, serif; font-size: 23px; color: #333333; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dadada; padding: 0px;"><span style="font-variant: normal !important; text-align: left !important;">Getting Column Information</span></h2>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">You can retrieve information about the columns of the most recent query result with <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">get_col_info</code>. This can be useful when a function has returned an OBJECT whose properties you don&#8217;t know. The function will output the desired information from the specified column, or an array with information on <em style="font-variant: normal !important; text-align: left !important;">all</em> columns from the query result if no column is specified.</p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><span style="font-variant: normal !important; text-align: left !important; color: #000000;"> <span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">&lt;?php $wpdb</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">-&gt;</span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">get_col_info</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">(</span><span style="font-variant: normal !important; text-align: left !important; color: #dd0000;">'type'</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">, </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">offset</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">); </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">?&gt;</span> </span> </code></p>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">type </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">(string) What information you wish to retrieve. May take on any of the following values (list taken from the <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="http://justinvincent.com/home/docs/ezsql/ez_sql_help.htm" href="http://justinvincent.com/home/docs/ezsql/ez_sql_help.htm">ezSQL docs</a>). Defaults to <strong style="font-variant: normal !important; text-align: left !important;">name</strong>.</p>
<ul style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 16px; list-style-type: square; list-style-position: initial; list-style-image: initial; padding: 0px;">
<li style="font-variant: normal !important; text-align: left !important; padding: 0px; margin: 0px;">name &#8211; column name. Default.</li>
<li style="font-variant: normal !important; text-align: left !important; padding: 0px; margin: 0px;">table &#8211; name of the table the column belongs to</li>
<li style="font-variant: normal !important; text-align: left !important; padding: 0px; margin: 0px;">max_length &#8211; maximum length of the column</li>
<li style="font-variant: normal !important; text-align: left !important; padding: 0px; margin: 0px;">not_null &#8211; 1 if the column cannot be NULL</li>
<li style="font-variant: normal !important; text-align: left !important; padding: 0px; margin: 0px;">primary_key &#8211; 1 if the column is a primary key</li>
<li style="font-variant: normal !important; text-align: left !important; padding: 0px; margin: 0px;">unique_key &#8211; 1 if the column is a unique key</li>
<li style="font-variant: normal !important; text-align: left !important; padding: 0px; margin: 0px;">multiple_key &#8211; 1 if the column is a non-unique key</li>
<li style="font-variant: normal !important; text-align: left !important; padding: 0px; margin: 0px;">numeric &#8211; 1 if the column is numeric</li>
<li style="font-variant: normal !important; text-align: left !important; padding: 0px; margin: 0px;">blob &#8211; 1 if the column is a BLOB</li>
<li style="font-variant: normal !important; text-align: left !important; padding: 0px; margin: 0px;">type &#8211; the type of the column</li>
<li style="font-variant: normal !important; text-align: left !important; padding: 0px; margin: 0px;">unsigned &#8211; 1 if the column is unsigned</li>
<li style="font-variant: normal !important; text-align: left !important; padding: 0px; margin: 0px;">zerofill &#8211; 1 if the column is zero-filled</li>
</ul>
</dd>
</dl>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">offset </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">(integer) Specify the column from which to retrieve information (with <strong style="font-variant: normal !important; text-align: left !important;">0</strong> being the first column). Defaults to <strong style="font-variant: normal !important; text-align: left !important;">-1</strong>.</p>
<ul style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 16px; list-style-type: square; list-style-position: initial; list-style-image: initial; padding: 0px;">
<li style="font-variant: normal !important; text-align: left !important; padding: 0px; margin: 0px;">-1 &#8211; Retrieve information from all columns. Output as array. Default.</li>
<li style="font-variant: normal !important; text-align: left !important; padding: 0px; margin: 0px;">Non-negative integer &#8211; Retrieve information from specified column (<strong style="font-variant: normal !important; text-align: left !important;">0</strong> being the first).</li>
</ul>
</dd>
</dl>
<p><a id="Clearing_the_Cache" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Clearing_the_Cache"></a></p>
<h2 style="font-variant: normal !important; text-align: left !important; margin-top: 22px; margin-right: 0px; margin-bottom: 11px; margin-left: 0px; font-style: normal; font-weight: normal; font-family: Georgia, 'Times New Roman', Times, serif; font-size: 23px; color: #333333; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dadada; padding: 0px;"><span style="font-variant: normal !important; text-align: left !important;">Clearing the Cache</span></h2>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">You can clear the SQL result cache with <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">flush</code>.</p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;"><code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;"><span style="font-variant: normal !important; text-align: left !important; color: #000000;"> <span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">&lt;?php $wpdb</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">-&gt;</span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">flush</span><span style="font-variant: normal !important; text-align: left !important; color: #007700;">(); </span><span style="font-variant: normal !important; text-align: left !important; color: #0000bb;">?&gt;</span> </span> </code></p>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">This clears <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">$wpdb-&gt;last_result</code>, <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">$wpdb-&gt;last_query</code>, and <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">$wpdb-&gt;col_info</code>.</p>
<p><a id="Class_Variables" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Class_Variables"></a></p>
<h2 style="font-variant: normal !important; text-align: left !important; margin-top: 22px; margin-right: 0px; margin-bottom: 11px; margin-left: 0px; font-style: normal; font-weight: normal; font-family: Georgia, 'Times New Roman', Times, serif; font-size: 23px; color: #333333; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dadada; padding: 0px;"><span style="font-variant: normal !important; text-align: left !important;">Class Variables</span></h2>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">$show_errors </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">Whether or not <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" href="http://codex.wordpress.org/Function_Reference/wpdb_Class#Showing_and_Hiding_SQL_Errors">Error echoing</a> is turned on. Defaults to TRUE.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">$num_queries </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">The number of queries that have been executed.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">$last_query </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">The most recent query to have been executed.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">$queries </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">You may save all of the queries run on the database and their stop times by setting the SAVEQUERIES constant to TRUE (this constant defaults to FALSE). If SAVEQUERIES is TRUE, your queries will be stored in this variable as an array.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">$last_result </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">The most recent query results.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">$col_info </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">The column information for the most recent query results. See <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" href="http://codex.wordpress.org/Function_Reference/wpdb_Class#Getting_Column_Information">Getting Column Information</a>.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">$insert_id </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">ID generated for an AUTO_INCREMENT column by the most recent INSERT query.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">$num_rows </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">The number of rows returned by the last query.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">$prefix</dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">The assigned WordPress table prefix for the site.</dd>
</dl>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">If you are using Multi-Site, you also have access to the following:</p>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">$blogid</dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">The id of the current site (blog).</dd>
</dl>
<p><a id="Tables" style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" name="Tables"></a></p>
<h2 style="font-variant: normal !important; text-align: left !important; margin-top: 22px; margin-right: 0px; margin-bottom: 11px; margin-left: 0px; font-style: normal; font-weight: normal; font-family: Georgia, 'Times New Roman', Times, serif; font-size: 23px; color: #333333; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dadada; padding: 0px;"><span style="font-variant: normal !important; text-align: left !important;">Tables</span></h2>
<p style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; clear: left; padding: 0px;">The WordPress database tables are easily referenced in the <code style="font-variant: normal !important; text-align: left !important; font-style: normal; font-weight: inherit; font-family: Consolas, Monaco, 'Courier New', Courier, monospace; color: #000000; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f0f0f0; margin-bottom: 22px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial;">wpdb</code> class.</p>
<dl style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 22px; margin-left: 0px; padding: 0px;">
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">$posts </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">The table of <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Database Description" href="http://codex.wordpress.org/Database_Description#Table:_wp_posts">Posts</a>.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">$users </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">The table of <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Database Description" href="http://codex.wordpress.org/Database_Description#Table:_wp_users">Users</a>.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">$comments </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">The <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Database Description" href="http://codex.wordpress.org/Database_Description#Table:_wp_comments">Comments</a> table.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">$links </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">The table of <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Database Description" href="http://codex.wordpress.org/Database_Description#Table:_wp_links">Links</a>.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">$options </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">The <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Database Description" href="http://codex.wordpress.org/Database_Description#Table:_wp_options">Options</a> table.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">$postmeta </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">The <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Database Description" href="http://codex.wordpress.org/Database_Description#Table:_wp_postmeta">Meta Content</a> (a.k.a. <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Custom Fields" href="http://codex.wordpress.org/Custom_Fields">Custom Fields</a>) table.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">$usermeta </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">The <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Database Description" href="http://codex.wordpress.org/Database_Description#Table:_wp_usermeta">usermeta</a> table contains additional user information, such as nicknames, descriptions and permissions.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">$terms </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">The <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Database Description" href="http://codex.wordpress.org/Database_Description#Table:_wp_terms">terms</a> table contains the &#8216;description&#8217; of Categories, Link Categories, Tags.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">$term_taxonomy </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">The <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Database Description" href="http://codex.wordpress.org/Database_Description#Table:_wp_term_taxonomy">term_taxonomy</a> table describes the various taxonomies (classes of terms). Categories, Link Categories, and Tags are taxonomies.</dd>
<dt style="font-variant: normal !important; text-align: left !important; font-weight: bold; font-size: 13px; padding: 0px; margin: 0px;">$term_relationships </dt>
<dd style="font-variant: normal !important; text-align: left !important; margin-top: 0px; margin-right: 0px; margin-bottom: 11px; margin-left: 1em; padding: 0px;">The <a style="font-variant: normal !important; text-align: left !important; text-decoration: none; color: #21759b; font-weight: normal;" title="Database Description" href="http://codex.wordpress.org/Database_Description#Table:_wp_term_relationships">term relationships</a> table contains link between the term and the object that uses that term, meaning this file point to each Category used for each Post.</dd>
</dl>
]]></content:encoded>
			<wfw:commentRss>http://www.result-search.com/m/lyman/227.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Function Reference/WP Query</title>
		<link>http://www.result-search.com/m/lyman/225.html</link>
		<comments>http://www.result-search.com/m/lyman/225.html#comments</comments>
		<pubDate>Sat, 16 Apr 2011 13:56:25 +0000</pubDate>
		<dc:creator>lyman</dc:creator>
				<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.result-search.com/m/?p=225</guid>
		<description><![CDATA[Role of WP_Query
WP_Query is a class defined in wp-includes/query.php that deals with the intricacies of a request to a WordPress blog. The wp-blog-header.php (or the WP class in Version 2.0) gives the $wp_query object  information defining the current request, and then $wp_query determines what type of query it&#8217;s dealing with (possibly a category  [...]]]></description>
			<content:encoded><![CDATA[<h2><span>Role of WP_Query</span></h2>
<p><tt>WP_Query</tt> is a class defined in <code><a title="http://core.trac.wordpress.org/browser/tags/3.1.1/wp-includes/query.php" href="http://core.trac.wordpress.org/browser/tags/3.1.1/wp-includes/query.php">wp-includes/query.php</a></code> that deals with the intricacies of a request to a WordPress blog. The <tt>wp-blog-header.php</tt> (or the WP class in <a title="Version 2.0" href="http://codex.wordpress.org/Version_2.0">Version 2.0</a>) gives the <tt>$wp_query</tt> object  information defining the current request, and then <tt>$wp_query</tt> determines what type of query it&#8217;s dealing with (possibly a category  archive, dated archive, feed, or search), and fetches the requested  posts. It retains a lot of information on the request, which can be  pulled at a later date.</p>
<p><a id="Methods_and_Properties" name="Methods_and_Properties"></a></p>
<h2><span>Methods and Properties</span></h2>
<p>This is the formal documentation of <tt>WP_Query</tt>. You shouldn&#8217;t  alter the properties directly, but instead use the methods to interact  with them. Also see <a href="http://codex.wordpress.org/Function_Reference/WP_Query#Interacting_with_WP_Query">Interacting with WP_Query</a> for some useful functions that  avoid the need to mess around with class internals and global variables.</p>
<p><a id="Properties" name="Properties"></a></p>
<h3><span>Properties</span></h3>
<dl>
<dt><tt>$query</tt></dt>
<dd>Holds the query string that was passed to  the $wp_query object by  WP class. </dd>
<dt><tt>$query_vars</tt></dt>
<dd>An associative array containing  the dissected <tt>$query</tt>: an array of the query variables and their  respective values. </dd>
<dt><tt>$queried_object</tt></dt>
<dd>Applicable if the request is a  category, author, permalink or Page. Holds information on the requested  category, author, post or Page. </dd>
<dt><tt>$queried_object_id</tt></dt>
<dd>If the request is a  category, author, permalink or page, holds the corresponding ID. </dd>
<dt><tt>$posts</tt></dt>
<dd>Gets filled with the requested posts  from the database. </dd>
<dt><tt>$post_count</tt></dt>
<dd>The number of posts being  displayed. </dd>
<dt><tt>$current_post</tt></dt>
<dd>(available during <a title="The Loop" href="http://codex.wordpress.org/The_Loop">The Loop</a>)  Index of the post currently being displayed. </dd>
<dt><tt>$post</tt></dt>
<dd>(available during <a title="The Loop" href="http://codex.wordpress.org/The_Loop">The Loop</a>)  The post currently being displayed. </dd>
<dt><tt>$is_single</tt>, <tt>$is_page</tt>, <tt>$is_archive</tt>, <tt>$is_preview</tt>,  <tt>$is_date</tt>, <tt>$is_year</tt>, <tt>$is_month</tt>, <tt>$is_time</tt>,  <tt>$is_author</tt>,  <tt>$is_category</tt>, <tt>$is_tag</tt>, <tt>$is_tax</tt>, <tt>$is_search</tt>,  <tt>$is_feed</tt>, <tt>$is_comment_feed</tt>, <tt>$is_trackback</tt>, <tt>$is_home</tt>,  <tt>$is_404</tt>, <tt>$is_comments_popup</tt>, <tt>$is_admin</tt>, <tt>$is_attachment</tt>,  <tt>$is_singular</tt>, <tt>$is_robots</tt>, <tt>$is_posts_page</tt>, <tt>$is_paged</tt></dt>
<dd><a title="Glossary" href="http://codex.wordpress.org/Glossary#Boolean">Booleans</a> dictating what type of request this is. For example, the first three  represent &#8216;is it a permalink?&#8217;, &#8216;is it a Page?&#8217;, &#8216;is it any type of  archive page?&#8217;, respectively. </dd>
</dl>
<p><a id="Methods" name="Methods"></a></p>
<h3><span>Methods</span></h3>
<p>(An ampersand (&amp;) before a method name indicates it <a title="http://www.php.net/manual/en/language.references.return.php" href="http://www.php.net/manual/en/language.references.return.php">returns  by reference</a>.)</p>
<dl>
<dt> <tt>init()</tt> </dt>
<dd> Initialise the object, set all properties to null, zero or  false. </dd>
<dt> <tt>parse_query($query)</tt> </dt>
<dd> Takes a query string defining the request, parses it and  populates all properties apart from <tt>$posts</tt>, <tt>$post_count</tt>,  <tt>$post</tt> and <tt>$current_post</tt>. </dd>
<dt> <tt>parse_query_vars()</tt> </dt>
<dd> Reparse the old query string. </dd>
<dt> <tt>get($query_var)</tt> </dt>
<dd> Get a named query variable. </dd>
<dt> <tt>set($query_var, $value)</tt> </dt>
<dd> Set a named query variable to a specific value. </dd>
<dt> <tt>&amp;get_posts()</tt> </dt>
<dd> Fetch and return the requested posts from the database. Also  populate <tt>$posts</tt> and <tt>$post_count</tt>. </dd>
<dt> <tt>next_post()</tt> </dt>
<dd> (to be used when in <a title="The Loop" href="http://codex.wordpress.org/The_Loop">The Loop</a>)  Advance onto the next post in <tt>$posts</tt>. Increment <tt>$current_post</tt> and set <tt>$post</tt> to the (new) current post object (note: this  does not set the global <tt>$post</tt> variable, only the WP_Query  object&#8217;s instance variable.) Returns the current post object </dd>
<dt> <tt>the_post()</tt> </dt>
<dd> (to be used when in <a title="The Loop" href="http://codex.wordpress.org/The_Loop">The Loop</a>)  Advance onto the next post, and set the global <tt>$post</tt> variable. </dd>
<dt> <tt>have_posts()</tt> </dt>
<dd> (to be used when in <a title="The Loop" href="http://codex.wordpress.org/The_Loop">The Loop</a>,  or just before The Loop) Determine if we have posts remaining to be  displayed. </dd>
<dt> <tt>rewind_posts()</tt> </dt>
<dd> Reset <tt>$current_post</tt> and <tt>$post</tt>. </dd>
<dt> <tt>&amp;query($query)</tt> </dt>
<dd> Call <tt>parse_query()</tt> and <tt>get_posts()</tt>. Return  the results of <tt>get_posts()</tt>. </dd>
<dt> <tt>get_queried_object()</tt> </dt>
<dd> Set <tt>$queried_object</tt> if it&#8217;s not already set and  return it. </dd>
<dt> <tt>get_queried_object_id()</tt> </dt>
<dd> Set <tt>$queried_object_id</tt> if it&#8217;s not already set and  return it. </dd>
<dt> <tt>WP_Query($query = '')</tt> (constructor) </dt>
<dd> If you provide a query string, call <tt>query()</tt> with it. </dd>
</dl>
<p><a id="Interacting_with_WP_Query" name="Interacting_with_WP_Query"></a></p>
<h2><span>Interacting with WP_Query</span></h2>
<p>Most of the time you can find the information you want without  actually dealing with the class internals and globals variables. There  are a whole bunch of functions that you can call from anywhere that will  enable you to get the information you need.</p>
<p>There are two main scenarios you might want to use <tt>WP_Query</tt> in. The first is to find out what type of request WordPress is  currently dealing with. The <tt>$is_*</tt> properties are designed to  hold this information: use the <a title="Conditional  Tags" href="http://codex.wordpress.org/Conditional_Tags">Conditional Tags</a> to interact here. This is the more common  scenario to plugin writers (the second normally applies to theme  writers).</p>
<p>The second is during <a title="The Loop" href="http://codex.wordpress.org/The_Loop">The Loop</a>.  <tt>WP_Query</tt> provides numerous functions for common tasks within  The Loop. To begin with, <a title="Function Reference/have posts (page does not exist)" href="http://codex.wordpress.org/index.php?title=Function_Reference/have_posts&amp;action=edit&amp;redlink=1">have_posts()</a>,  which calls <tt>$wp_query-&gt;have_posts()</tt>, is called to see if  there are any posts to show. If there are, a <tt>while</tt> loop is  begun, using <a title="Function Reference/have posts (page does not exist)" href="http://codex.wordpress.org/index.php?title=Function_Reference/have_posts&amp;action=edit&amp;redlink=1">have_posts()</a> as the condition. This will iterate around as long as there are posts  to show. In each iteration, <a title="Function Reference/the post" href="http://codex.wordpress.org/Function_Reference/the_post">the_post()</a>,  which calls <tt>$wp_query-&gt;the_post()</tt> is called, setting up  internal variables within <tt>$wp_query</tt> and the global <tt>$post</tt> variable (which the <a title="Template Tags" href="http://codex.wordpress.org/Template_Tags">Template Tags</a> rely on), as above. These are  the functions you should use when writing a theme file that needs a  loop. See also <a title="The  Loop" href="http://codex.wordpress.org/The_Loop">The Loop</a> and <a title="The Loop in  Action" href="http://codex.wordpress.org/The_Loop_in_Action">The Loop in Action</a> for more information.</p>
<p><strong>Note:</strong> If you use <a title="Function Reference/the post" href="http://codex.wordpress.org/Function_Reference/the_post">the_post()</a> with your query, you need to run <a title="Function Reference/wp reset postdata (page does not  exist)" href="http://codex.wordpress.org/index.php?title=Function_Reference/wp_reset_postdata&amp;action=edit&amp;redlink=1">wp_reset_postdata()</a> afterwards to have <a title="Template Tags" href="http://codex.wordpress.org/Template_Tags">Template  Tags</a> use the main query&#8217;s current post again.</p>
<p><a id="Example" name="Example"></a></p>
<h2><span>Example</span></h2>
<p>Using WP_Query to retrieve only pages given in a specific array</p>
<pre>&lt;?php
$args = array(
	'post_type' =&gt; 'page',
	'post__in'  =&gt; array( '595', '33', 44 )
);
$the_query = new WP_Query( $args );
?&gt;</pre>
<p><a id="Parameters" name="Parameters"></a></p>
<h2><span>Parameters</span></h2>
<p><a id="Author_Parameters" name="Author_Parameters"></a></p>
<h3><span>Author Parameters</span></h3>
<p>Show posts associated with certain author.</p>
<ul>
<li> <strong><tt>author</tt></strong> (<em>int</em>) &#8211; use author id.</li>
<li> <strong><tt>author_name</tt></strong> (<em>string</em>) &#8211; use &#8216;<tt>user_nicename</tt>&#8216;  (NOT name).</li>
</ul>
<p><strong>Show Posts for one Author</strong></p>
<p>Display posts by author, using author id:</p>
<pre>$query = new WP_Query( 'author=123' );</pre>
<p>Display posts by author, using author &#8216;<tt>user_nicename</tt>&#8216;:</p>
<pre>$query = new WP_Query( 'author_name=rami' );</pre>
<p><strong>Show Posts From Several Authors</strong></p>
<p>Display posts from several specific authors:</p>
<pre>$query = new WP_Query( 'author=2,6,17,38' );</pre>
<p><strong>Exclude Posts Belonging to an Author</strong></p>
<p>Display all posts <em>except</em> those from an author by prefixing  its id with a &#8216;-&#8217; (minus) sign:</p>
<pre>$query = new WP_Query( 'author=-12,-34,-56' );</pre>
<p><a id="Category_Parameters" name="Category_Parameters"></a></p>
<h3><span>Category Parameters</span></h3>
<p>Show posts associated with certain categories.</p>
<ul>
<li> <strong><tt>cat</tt></strong> (<em>int</em>) &#8211; use category id.</li>
<li> <strong><tt>category_name</tt></strong> (<em>string</em>) &#8211; use category  slug (NOT name).</li>
<li> <strong><tt>category__and</tt></strong> (<em>array</em>) &#8211; use category  id.</li>
<li> <strong><tt>category__in</tt></strong> (<em>array</em>) &#8211; use category id.</li>
<li> <strong><tt>category__not_in</tt></strong> (<em>array</em>) &#8211; use category  id.</li>
</ul>
<p><strong>Show Posts for One Category</strong></p>
<p>Display posts that have this category (and any children of that  category), using category id:</p>
<pre>$query = new WP_Query( 'cat=4' );</pre>
<p>Display posts that have this category (and any children of that  category), using category slug:</p>
<pre>$query = new WP_Query( 'category_name=staff' );</pre>
<p><strong>Show Posts From Several Categories</strong></p>
<p>Display posts that have these categories, using category id:</p>
<pre>$query = new WP_Query( 'cat=2,6,17,38' );</pre>
<p>Display posts that have these categories, using category slug (not  possible with wp3.0):</p>
<pre>$query = new WP_Query( 'category_name=staff,news' );</pre>
<p><strong>Exclude Posts Belonging to Category</strong></p>
<p>Display all posts <em>except</em> those from a category by  prefixing its id with a &#8216;-&#8217; (minus) sign.</p>
<pre>$query = new WP_Query( 'cat=-12,-34,-56' );</pre>
<p><strong>Multiple Category Handling</strong></p>
<p>Display posts that are in multiple categories.  This shows posts  that are in both categories 2 and 6:</p>
<pre>$query = new WP_Query( array( 'category__and' =&gt; array( 2, 6 ) ) );</pre>
<p>To display posts from either category 2 OR 6, you could use <tt>cat</tt> as mentioned above, or by using <tt>category__in</tt> (note this does  not show posts from any children of these categories):</p>
<pre>$query = new WP_Query( array( 'category__in' =&gt; array( 2, 6 ) ) );</pre>
<p>You can also exclude multiple categories this way:</p>
<pre>$query = new WP_Query( array( 'category__not_in' =&gt; array( 2, 6 ) ) );</pre>
<p><a id="Tag_Parameters" name="Tag_Parameters"></a></p>
<h3><span>Tag Parameters</span></h3>
<p>Show posts associated with certain tags.</p>
<ul>
<li> <strong><tt>tag</tt></strong> (<em>string</em>) &#8211; use tag slug.</li>
<li> <strong><tt>tag_id</tt></strong> (<em>int</em>) &#8211; use tag id.</li>
<li> <strong><tt>tag__and</tt></strong> (<em>array</em>) &#8211; use tag ids.</li>
<li> <strong><tt>tag__in</tt></strong> (<em>array</em>) &#8211; use tag ids.</li>
<li> <strong><tt>tag__not_in</tt></strong> (<em>array</em>) &#8211; use tag ids.</li>
<li> <strong><tt>tag_slug__and</tt></strong> (<em>array</em>) &#8211; use tag slugs.</li>
<li> <strong><tt>tag_slug__in</tt></strong> (<em>array</em>) &#8211; use tag slugs.</li>
</ul>
<p><strong>Show Posts for One Tag</strong></p>
<p>Display posts that have this tag, using tag slug:</p>
<pre>$query = new WP_Query( 'tag=cooking' );</pre>
<p>Display posts that have this tag, using tag id:</p>
<pre>$query = new WP_Query( 'tag_id=13' );</pre>
<p><strong>Show Posts From Several Tags</strong></p>
<p>Display posts that have &#8220;either&#8221; of these tags:</p>
<pre>$query = new WP_Query( 'tag=bread,baking' );</pre>
<p>Display posts that have &#8220;all&#8221; of these tags:</p>
<pre>$query = new WP_Query( 'tag=bread+baking+recipe' );</pre>
<p><strong>Multiple Tag Handling</strong></p>
<p>Display posts that are tagged with both tag id 37 and tag id 47:</p>
<pre>$query = new WP_Query( array( 'tag__and' =&gt; array( 37, 47 ) ) );</pre>
<p>To display posts from either tag id 37 or 47, you could use <tt>tag</tt> as mentioned above, or explicitly specify by using <tt>tag__in</tt>:</p>
<pre>$query = new WP_Query( array( 'tag__in' =&gt; array( 37, 47 ) ) );</pre>
<p>Display posts that do not have any of the two tag ids 37 and 47:</p>
<pre>$query = new WP_Query( array( 'tag__not_in' =&gt; array( 37, 47 ) ) );</pre>
<p>The <tt>tag_slug__in</tt> and <tt>tag_slug__and</tt> behave much the  same, except match against the tag&#8217;s slug.</p>
<p><a id="Taxonomy_Parameters" name="Taxonomy_Parameters"></a></p>
<h3><span>Taxonomy Parameters</span></h3>
<p>Show posts associated with certain <a title="Taxonomies" href="http://codex.wordpress.org/Taxonomies">taxonomy</a>.</p>
<ul>
<li> <strong><tt>{tax}</tt></strong> (<em>string</em>) &#8211; use taxonomy slug. <strong>Deprecated</strong> as of <a title="Version  3.1" href="http://codex.wordpress.org/Version_3.1">Version 3.1</a> in favor of &#8216;<tt>tax_query</tt>&#8216;.</li>
<li> <strong><tt>tax_query</tt></strong> (<em>array</em>) &#8211; use taxonomy  parameters (available with <a title="Version 3.1" href="http://codex.wordpress.org/Version_3.1">Version  3.1</a>).
<ul>
<li> <strong><tt>taxonomy</tt></strong> (<em>string</em>) &#8211; Taxonomy.</li>
<li> <strong><tt>field</tt></strong> (<em>string</em>) &#8211;  Select taxonomy term  by (&#8217;id&#8217; or &#8217;slug&#8217;)</li>
<li> <strong><tt>terms</tt></strong> (<em>int/string/array</em>) &#8211; Taxonomy  term(s).</li>
<li> <strong><tt>operator</tt></strong> (<em>string</em>) &#8211; Operator to test.  Possible values are &#8216;LIKE&#8217;, &#8216;NOT LIKE&#8217;, &#8216;IN&#8217;, &#8216;NOT IN&#8217;, &#8216;BETWEEN&#8217;, &#8216;NOT  BETWEEN&#8217;.</li>
</ul>
</li>
</ul>
<p><strong>Simple Taxonomy Query:</strong></p>
<p>Display posts tagged with &#8216;bob&#8217;, under &#8216;people&#8217; custom taxonomy:</p>
<pre>$query = new WP_Query( array( 'people' =&gt; 'bob' ) );</pre>
<p>Display posts tagged with &#8216;bob&#8217;, under &#8216;people&#8217; custom taxonomy,  using &#8216;tax_query&#8217;:</p>
<pre>$args = array(
	'tax_query' =&gt; array(
		array(
			'taxonomy' =&gt; 'people',
			'field' =&gt; 'slug',
			'terms' =&gt; 'bob'
		)
	)
);
$query = new WP_Query( $args );</pre>
<p><strong>Multiple Taxonomy Handling:</strong></p>
<p>Display posts from several custom taxonomies:</p>
<pre>$query = new WP_Query( array( 'people' =&gt; 'bob', 'language' =&gt; 'english' ) );</pre>
<p>Display posts from several custom taxonomies, using &#8216;tax_query&#8217;:</p>
<pre>$args = array(
	'tax_query' =&gt; array(
		'relation' =&gt; 'AND',
		array(
			'taxonomy' =&gt; 'movie_janner',
			'field' =&gt; 'slug',
			'terms' =&gt; array( 'action', 'commedy' ),
		),
		array(
			'taxonomy' =&gt; 'actor',
			'field' =&gt; 'id',
			'terms' =&gt; array( 103, 115, 206 ),
			'operator' =&gt; 'NOT IN',
		)
	)
)
$query = new WP_Query( $args );</pre>
<p>Display posts that are in the &#8216;quotes&#8217; category OR have the &#8216;quote&#8217; <a title="Post Formats" href="http://codex.wordpress.org/Post_Formats">format</a>:</p>
<pre>$args = array(
	'tax_query' =&gt; array(
		'relation' =&gt; 'OR',
		array(
			'taxonomy' =&gt; 'category',
			'field' =&gt; 'slug',
			'terms' =&gt; array( 'quotes' ),
		),
		array(
			'taxonomy' =&gt; 'post_format',
			'field' =&gt; 'slug',
			'terms' =&gt; array( 'post-format-quote' )
		)
	)
)
$query = new WP_Query( $args );</pre>
<p><a id="Post_.26_Page_Parameters" name="Post_.26_Page_Parameters"></a></p>
<h3><span>Post &amp; Page Parameters</span></h3>
<p>Show posts associated with posts and pages.</p>
<ul>
<li> <strong><tt>p</tt></strong> (<em>int</em>) &#8211; use post id.</li>
<li> <strong><tt>name</tt></strong> (<em>string</em>) &#8211; use post slug.</li>
<li> <strong><tt>page_id</tt></strong> (<em>int</em>) &#8211; use page id.</li>
<li> <strong><tt>pagename</tt></strong> (<em>string</em>) &#8211; use page slug.</li>
<li> <strong><tt>post_parent</tt></strong> (<em>int</em>) &#8211; use page id. Return  just the child Pages.</li>
<li> <strong><tt>post__in</tt></strong> (<em>array</em>) &#8211; use post ids.  Specify posts to retrieve.</li>
<li> <strong><tt>post__not_in</tt></strong> (<em>array</em>) &#8211; use post ids.  Specify post NOT to retrieve.</li>
</ul>
<p><strong>Show Post/Page by ID</strong></p>
<p>Display post by his ID:</p>
<pre>$query = new WP_Query( 'p=7' );</pre>
<p>Display page by his ID:</p>
<pre>$query = new WP_Query( 'page_id=7' );</pre>
<p><strong>Show Post/Page by Slug</strong></p>
<p>Display post by his <tt>slug</tt>:</p>
<pre>$query = new WP_Query( 'name=about-my-life' );</pre>
<p>Display page by his <tt>slug</tt>:</p>
<pre>$query = new WP_Query( 'pagename=contact' );</pre>
<p><strong>Show Child Posts/Pages</strong></p>
<p>Display child page using the slug of the parent and the child  page, separated by a slash (e.g. &#8216;parent_slug/child_slug&#8217;):</p>
<pre>$query = new WP_Query( 'pagename=contact_us/canada' );</pre>
<p>Display child pages using parent page ID:</p>
<pre>$query = new WP_Query( 'post_parent=93' );</pre>
<p><strong>Multiple Posts/Pages Handling</strong></p>
<p>Display only the specify posts:</p>
<pre>$query = new WP_Query( array( 'post__in' =&gt; array( 2, 5, 12, 14, 20 ) ) );</pre>
<p>Display all posts but NOT the specify ones:</p>
<pre>$query = new WP_Query( array( 'post__not_in' =&gt; array( 2, 5, 12, 14, 20 ) ) );</pre>
<p>Note: you cannot combine &#8216;post__in&#8217; and &#8216;post__not_in&#8217; in the same  query.</p>
<p><a id="Type_.26_Status_Parameters" name="Type_.26_Status_Parameters"></a></p>
<h3><span>Type &amp; Status Parameters</span></h3>
<p>Show posts associated with certain <a title="Post Types" href="http://codex.wordpress.org/Post_Types">type</a> or <a title="Post Status (page does not exist)" href="http://codex.wordpress.org/index.php?title=Post_Status&amp;action=edit&amp;redlink=1">status</a>.</p>
<ul>
<li> <strong><tt>post_type</tt></strong> (<em>string</em> / <em>array</em>) &#8211; use  post types. Retrieves posts by <a title="Post Types" href="http://codex.wordpress.org/Post_Types">Post  Types</a>, default value is &#8216;<tt>post</tt>&#8216;;
<ul>
<li> &#8216;<tt>post</tt>&#8216;</li>
<li> &#8216;<tt>page</tt>&#8216;</li>
<li> &#8216;<tt>revision</tt>&#8216;</li>
<li> &#8216;<tt>attachment</tt>&#8216; &#8211; The default WP_Query sets  &#8217;status&#8217;=&gt;&#8217;published&#8217;, but attachments default to  &#8217;status&#8217;=&gt;&#8217;inherit&#8217; so you&#8217;ll need to set the status to &#8216;inherit&#8217; or  &#8216;all&#8217;</li>
<li> &#8216;<tt>any</tt>&#8216; &#8211; retrieves any type except revisions</li>
<li> Custom Post Types (e.g. movies)</li>
</ul>
</li>
<li> <strong><tt>post_status</tt></strong> (<em>string</em> / <em>array</em>) &#8211;  use post status. Retrieves posts by <a title="Post Status (page does not exist)" href="http://codex.wordpress.org/index.php?title=Post_Status&amp;action=edit&amp;redlink=1">Post Status</a>,  default value is &#8216;<tt>publish</tt>&#8216; &#8211; Note: Use a Comma separated list  to query multiple values in pre-3.2, <a title="http://core.trac.wordpress.org/ticket/16824" href="http://core.trac.wordpress.org/ticket/16824">See #16824</a>;
<ul>
<li> &#8216;<tt>publish</tt>&#8216; &#8211; a published post or page</li>
<li> &#8216;<tt>pending</tt>&#8216; &#8211; post is pending review</li>
<li> &#8216;<tt>draft</tt>&#8216; &#8211; a post in draft status</li>
<li> &#8216;<tt>auto-draft</tt>&#8216; &#8211; a newly created post, with no content</li>
<li> &#8216;<tt>future</tt>&#8216; &#8211; a post to publish in the future</li>
<li> &#8216;<tt>private</tt>&#8216; &#8211; not visible to users who are not logged  in</li>
<li> &#8216;<tt>inherit</tt>&#8216; &#8211; a revision. see <a title="Function Reference/get children" href="http://codex.wordpress.org/Function_Reference/get_children">get_children</a>.</li>
<li> &#8216;<tt>trash</tt>&#8216; &#8211; post is in trashbin. added with <a title="Version 2.9" href="http://codex.wordpress.org/Version_2.9">Version  2.9</a>.</li>
</ul>
</li>
</ul>
<p><strong>Show Post by Type</strong></p>
<p>Display only pages:</p>
<pre>$query = new WP_Query( 'post_type=page' );</pre>
<p>Display &#8216;<tt>any</tt>&#8216; post type (retrieves any type except  revisions):</p>
<pre>$query = new WP_Query( 'post_type=any' );</pre>
<p>Display multiple post types, including custom post types:</p>
<pre>$query = new WP_Query( array( 'post_type' =&gt; array( 'post', 'page', 'movie', 'book' ) ) );</pre>
<p><strong>Show Post by Status</strong></p>
<p>Display only drafts:</p>
<pre>$query = new WP_Query( 'post_status=draft' );</pre>
<p>Display multiple post status:</p>
<pre>$query = new WP_Query( array( 'post_status' =&gt; array( 'pending', 'draft', 'future' ) ) );</pre>
<p>Display all attachments:</p>
<pre>$query = new WP_Query( array( 'post_status' =&gt; 'all', 'post_type' =&gt; 'attachment' ) );</pre>
<p><a id="Pagination_Parameters" name="Pagination_Parameters"></a></p>
<h3><span>Pagination Parameters</span></h3>
<ul>
<li> <strong><tt>showposts</tt></strong> (<em>int</em>) &#8211; number of post to show  per page. <strong>Deprecated</strong> as of <a title="Version 2.1" href="http://codex.wordpress.org/Version_2.1">Version  2.1</a> in favor of &#8216;posts_per_page&#8217;.</li>
<li> <strong><tt>posts_per_page</tt></strong> (<em>int</em>) &#8211; number of post  to show per page (available with <a title="Version 2.1" href="http://codex.wordpress.org/Version_2.1">Version  2.1</a>). Use <tt>'posts_per_page'=&gt;-1</tt> to show all posts. Note  if the query is in a feed, wordpress overwrites this parameter with the  stored &#8216;posts_per_rss&#8217; option. To reimpose the limit, try using the  &#8216;post_limits&#8217; filter.</li>
<li> <strong><tt>nopaging</tt></strong> (<em>bool</em>) &#8211; show all posts or use  pagination. Default value is &#8216;false&#8217;, use paging.</li>
<li> <strong><tt>paged</tt></strong> (<em>int</em>) &#8211; number of page. Show the  posts that would normally show up just on page X when using the &#8220;Older  Entries&#8221; link.</li>
</ul>
<p><strong>Show x Posts per page</strong></p>
<p>Display 3 posts per page:</p>
<pre>$query = new WP_Query( 'posts_per_page=3' );</pre>
<p><strong>Show All Post</strong></p>
<p>Display all posts in one page:</p>
<pre>$query = new WP_Query( 'posts_per_page=-1' );</pre>
<p>Display all posts by disabling pagination:</p>
<pre>$query = new WP_Query( 'nopaging=true' );</pre>
<p><strong>Show Posts from page x</strong></p>
<p>Display posts from page number 6:</p>
<pre>$query = new WP_Query( 'paged=6' );</pre>
<p><strong>Show Posts from Current Page</strong></p>
<p>Display posts from current page:</p>
<pre>$query = new WP_Query( 'paged=' . get_query_var( 'page' ) );</pre>
<p>Pagination Note: You should set <tt>get_query_var( 'page' );</tt> if  you want your query to work with pagination. Since <a title="Version 3.0.2" href="http://codex.wordpress.org/Version_3.0.2">Wordpress  3.0.2</a>, you do <tt>get_query_var( 'page' )</tt> instead of <tt>get_query_var(  'paged' )</tt>. The pagination parameter &#8216;<tt>paged</tt>&#8216; for <tt>WP_Query()</tt> remains the same.</p>
<p><a id="Offset_Parameter" name="Offset_Parameter"></a></p>
<h3><span>Offset Parameter</span></h3>
<ul>
<li> <strong><tt>offset</tt></strong> (<em>int</em>) &#8211; number of post to <em>displace</em> or pass over.</li>
</ul>
<p><strong>Pass over 3 Posts</strong></p>
<p>Display posts from the 4th one:</p>
<pre>$query = new WP_Query( 'offset=3' ) );</pre>
<p><strong>Show 5 Posts starting from the second one</strong></p>
<p>Display 5 posts per page which follow the most recent (1):</p>
<pre>$query = new WP_Query( array( 'posts_per_page' =&gt; 5, 'offset' =&gt; 1 ) );</pre>
<p><a id="Order_.26_Orderby_Parameters" name="Order_.26_Orderby_Parameters"></a></p>
<h3><span>Order &amp; Orderby Parameters</span></h3>
<p>Sort retrieved posts.</p>
<ul>
<li> <strong><tt>order</tt></strong> (<em>string</em>) &#8211; Designates the  ascending or descending order of the &#8216;<tt>orderby</tt>&#8216; parameter.   Defaults to &#8216;DESC&#8217;.
<ul>
<li> &#8216;<tt>ASC</tt>&#8216; &#8211; ascending order from lowest to highest values  (1, 2, 3; a, b, c).</li>
<li> &#8216;<tt>DESC</tt>&#8216; &#8211; descending order from highest to lowest  values (3, 2, 1; c, b, a).  Default.</li>
</ul>
</li>
</ul>
<ul>
<li> <strong><tt>orderby</tt></strong> (<em>string</em>) &#8211; Sort retrieved posts  by:
<ul>
<li> &#8216;<tt>none</tt>&#8216; &#8211; No order (available with <a title="Version 2.8" href="http://codex.wordpress.org/Version_2.8">Version  2.8</a>).</li>
<li> &#8216;<tt>id</tt>&#8216; &#8211; Order by post id.</li>
<li> &#8216;<tt>author</tt>&#8216; &#8211; Order by author.</li>
<li> &#8216;<tt>title</tt>&#8216; &#8211; Order by title.</li>
<li> &#8216;<tt>date</tt>&#8216; &#8211; Order by date. (default, if not set to none)</li>
<li> &#8216;<tt>modified</tt>&#8216; &#8211; Order by last modified date.</li>
<li> &#8216;<tt>parent</tt>&#8216; &#8211; Order by post/page parent id.</li>
<li> &#8216;<tt>rand</tt>&#8216; &#8211; Random order.</li>
<li> &#8216;<tt>comment_count</tt>&#8216; &#8211; Order by number of comments  (available with <a title="Version 2.9" href="http://codex.wordpress.org/Version_2.9">Version 2.9</a>).</li>
<li> &#8216;<tt>menu_order</tt>&#8216; &#8211; Order by  Page Order. Used most often  for <a title="Pages" href="http://codex.wordpress.org/Pages">Pages</a> (<em>Order</em> field in the Edit Page Attributes box) and for <a title="attachments (page does not exist)" href="http://codex.wordpress.org/index.php?title=attachments&amp;action=edit&amp;redlink=1">attachments</a> (the integer fields in the Insert / Upload Media Gallery dialog), but  could be used for any post type with distinct &#8216;<tt>menu_order</tt>&#8216;  values (they all default to <var>0</var>).</li>
<li> &#8216;<tt>meta_value</tt>&#8216; &#8211; Note that a &#8216;<tt>meta_key=keyname</tt>&#8216;  must also be present in the query. Note also that the sorting will be  alphabetical which is fine for strings (i.e. words), but can be  unexpected for numbers (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3,  4, 6, 34, 56 as you might naturally expect).</li>
<li> &#8216;<tt>meta_value_num</tt>&#8216; &#8211; Order by numeric meta value  (available with <a title="Version 2.8" href="http://codex.wordpress.org/Version_2.8">Version 2.8</a>). Also note that a &#8216;<tt>meta_key=keyname</tt>&#8216;  must also be present in the query. This value allows for numerical  sorting as noted above in &#8216;<tt>meta_value</tt>&#8216;.</li>
</ul>
</li>
</ul>
<p><strong>Show Posts sorted by Title, Descending order</strong></p>
<p>Display posts sorted by post title in a descending order:</p>
<pre>$query = new WP_Query( 'orderby=title&amp;order=DESC' );</pre>
<p><strong>Show Random Post</strong></p>
<p>Display one random post:</p>
<pre>$query = new WP_Query( 'orderby=rand&amp;posts_per_page=1' );</pre>
<p><strong>Show Popular Posts</strong></p>
<p>Display posts ordered by comment count:</p>
<pre>$query = new WP_Query( 'orderby=comment_count' );</pre>
<p><strong>Show Products sorted by Price</strong></p>
<p>Display posts with &#8216;Product&#8217; type ordered by &#8216;Price&#8217; custom  field:</p>
<pre>$query = new WP_Query( array ( 'post_type' =&gt; 'product', 'orderby' =&gt; 'meta_value', 'meta_key' =&gt; 'price' ) );</pre>
<p><strong>Note, that there can be more than one orderby value.</strong></p>
<p>Display &#8216;page&#8217; post type ordered by &#8216;title&#8217; and &#8216;menu_order&#8217;.  (Separated with spaces to work properly.)</p>
<pre>$query = new WP_Query( 'post_type=page&amp;orderby=title menu_order&amp;order=ASC' );</pre>
<p><a id="Sticky_Post_Parameters" name="Sticky_Post_Parameters"></a></p>
<h3><span>Sticky Post Parameters</span></h3>
<p>Show <a title="Sticky  Posts" href="http://codex.wordpress.org/Sticky_Posts">Sticky Posts</a> or ignore them.</p>
<ul>
<li> <strong><tt>caller_get_posts</tt></strong> (<em>bool</em>) &#8211; ignore sticky  posts or not. <strong>Deprecated</strong> as of <a title="Version 3.1" href="http://codex.wordpress.org/Version_3.1">Version  3.1</a> in favor of &#8216;<tt>ignore_sticky_posts</tt>&#8216;.</li>
<li> <strong><tt>ignore_sticky_posts</tt></strong> (<em>bool</em>) &#8211; ignore  sticky posts or not. Default value is 0, don&#8217;t ignore. Ignore/exclude  sticky posts being included at the beginning of posts returned, but the  sticky post will still be returned in the natural order of that list of  posts returned.</li>
</ul>
<p><strong>Show Sticky Posts</strong></p>
<p>Display just the first sticky post:</p>
<pre>$sticky = get_option( 'sticky_posts' );
$query = new WP_Query( 'p=' . $sticky[0] );</pre>
<p>Display just the first sticky post, if none return the last post  published:</p>
<pre>$args = array(
	'posts_per_page' =&gt; 1,
	'post__in'  =&gt; get_option( 'sticky_posts' ),
	'ignore_sticky_posts' =&gt; 1
);
$query = new WP_Query( $args );</pre>
<p>Display just the first sticky post, if none return nothing:</p>
<pre>$sticky = get_option( 'sticky_posts' );
$args = array(
	'posts_per_page' =&gt; 1,
	'post__in'  =&gt; $sticky,
	'ignore_sticky_posts' =&gt; 1
);
$query = new WP_Query( $args );
if ( $sticky[0] ) {
	// insert here your stuff...
}</pre>
<p><strong>Don&#8217;t Show Sticky Posts</strong></p>
<p>Exclude all sticky posts from the query:</p>
<pre>$query = new WP_Query( array( 'post__not_in' =&gt; get_option( 'sticky_posts' ) ) );</pre>
<p>Exclude sticky posts from a category. Return ALL posts within the  category, but don&#8217;t show sticky posts at the top. The &#8217;sticky posts&#8217;  will still show in their natural position (e.g. by date):</p>
<pre>$query = new WP_Query( 'ignore_sticky_posts=1&amp;posts_per_page=3&amp;cat=6' );</pre>
<p>Exclude sticky posts from a category. Return posts within the  category, but exclude sticky posts completely, and adhere to paging  rules:</p>
<pre>$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$sticky = get_option( 'sticky_posts' );
$args = array(
	'cat' =&gt; 3,
	'ignore_sticky_posts' =&gt; 1,
	'post__not_in' =&gt; $sticky,
	'paged' =&gt; $paged
);
$query = new WP_Query( $args );</pre>
<p><a id="Time_Parameters" name="Time_Parameters"></a></p>
<h3><span>Time Parameters</span></h3>
<p>Show posts associated with a certain time period.</p>
<ul>
<li> <strong><tt>year</tt></strong> (<em>int</em>) &#8211; 4 digit year (e.g. 2011).</li>
<li> <strong><tt>monthnum</tt></strong> (<em>int</em>) &#8211; Month number (from 1  to 12).</li>
<li> <strong><tt>w</tt></strong> (<em>int</em>) &#8211; Week of the year (from 0 to  53). Uses the <a title="http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_week" href="http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_week">MySQL  WEEK command Mode=1</a>.</li>
<li> <strong><tt>day</tt></strong> (<em>int</em>) &#8211; Day of the month (from 1 to  31).</li>
<li> <strong><tt>hour</tt></strong> (<em>int</em>) &#8211; Hour (from 0 to 23).</li>
<li> <strong><tt>minute</tt></strong> (<em>int</em>) &#8211; Minute (from 0 to 60).</li>
<li> <strong><tt>second</tt></strong> (<em>int</em>) &#8211; Second (0 to 60).</li>
</ul>
<p><strong>Returns posts for just the current date:</strong></p>
<pre>$today = getdate();
$query = new WP_Query( 'year=' . $today["year"] . '&amp;monthnum=' . $today["mon"] . '&amp;day=' . $today["mday"] );</pre>
<p><strong>Returns posts for just the current week:</strong></p>
<pre>$week = date('W');
$year = date('Y');
$query = new WP_Query( 'year=' . $year . '&amp;w=' . $week );</pre>
<p><strong>Returns posts dated December 20:</strong></p>
<pre>$query = new WP_Query( 'monthnum=12&amp;day=20' );</pre>
<p><strong>Note:</strong> The queries above return posts for a specific date  period in history, i.e. &#8220;Posts from X year, X month, X day&#8221;. They are  unable to fetch posts from a timespan relative to the present, so  queries like &#8220;Posts from the last 30 days&#8221; or &#8220;Posts from the last year&#8221;  are not possible with a basic query, and require use of the posts_where  filter to be completed. The examples below use the posts_where <a title="Plugin API" href="http://codex.wordpress.org/Plugin_API#Filters"> filter</a>, and should be modifyable for most time-relative queries.</p>
<p><strong>Return posts for posts for March 1 to March 15, 2009:</strong></p>
<pre>// Create a new filtering function that will add our where clause to the query
function filter_where( $where = '' ) {
	// posts for March 1 to March 15, 2010
	$where .= " AND post_date &gt;= '2010-03-01' AND post_date &lt; '2010-03-16'";
	return $where;
}
add_filter( 'posts_where', 'filter_where' );

$query = new WP_Query( $query_string );</pre>
<p><strong>Return posts from the last 30 days:</strong></p>
<pre>// Create a new filtering function that will add our where clause to the query
function filter_where( $where = '' ) {
	// posts in the last 30 days
	$where .= " AND post_date &gt; '" . date('Y-m-d', strtotime('-30 days')) . "'";
	return $where;
}
add_filter( 'posts_where', 'filter_where' );

$query = new WP_Query( $query_string );</pre>
<p><strong>Return posts 30 to 60 days old</strong></p>
<pre>// Create a new filtering function that will add our where clause to the query
function filter_where( $where = '' ) {
	// posts  30 to 60 days old
	$where .= " AND post_date &gt;= '" . date('Y-m-d', strtotime('-60 days')) . "'" . " AND post_date &lt;= '" . date('Y-m-d', strtotime('-30 days')) . "'";
	return $where;
}
add_filter( 'posts_where', 'filter_where' );

$query = new WP_Query( $query_string );</pre>
<p><a id="Custom_Field_Parameters" name="Custom_Field_Parameters"></a></p>
<h3><span>Custom Field Parameters</span></h3>
<p>Show posts associated with a certain custom field.</p>
<ul>
<li> <strong><tt>meta_key</tt></strong> (<em>string</em>) &#8211; Custom field key. <strong>Deprecated</strong> as of <a title="Version  3.1" href="http://codex.wordpress.org/Version_3.1">Version 3.1</a> in favor of &#8216;<tt>meta_query</tt>&#8216;.</li>
<li> <strong><tt>meta_value</tt></strong> (<em>string</em>) &#8211; Custom field  value. <strong>Deprecated</strong> as of <a title="Version 3.1" href="http://codex.wordpress.org/Version_3.1">Version  3.1</a> in favor of &#8216;<tt>meta_query</tt>&#8216;.</li>
<li> <strong><tt>meta_compare</tt></strong> (<em>string</em>) &#8211; Operator to  test the &#8216;<tt>meta_value</tt>&#8216;. Possible values are &#8216;!=&#8217;, &#8216;&gt;&#8217;,  &#8216;&gt;=&#8217;, &#8216;&lt;&#8217;, or &#8216;&lt;=&#8217;. Default value is &#8216;=&#8217;. <strong>Deprecated</strong> as  of <a title="Version 3.1" href="http://codex.wordpress.org/Version_3.1">Version  3.1</a> in favor of &#8216;<tt>meta_query</tt>&#8216;.</li>
</ul>
<ul>
<li> <strong><tt>meta_query</tt></strong> (<em>array</em>) &#8211; Custom field  parameters (available with <a title="Version 3.1" href="http://codex.wordpress.org/Version_3.1">Version  3.1</a>).
<ul>
<li> <strong><tt>key</tt></strong> (<em>string</em>) &#8211; Custom field key.</li>
<li> <strong><tt>value</tt></strong> (<em>string</em>) &#8211; Custom field value.</li>
<li> <strong><tt>compare</tt></strong> (<em>string</em>) &#8211; Operator to test.  Possible values are &#8216;=&#8217;, &#8216;!=&#8217;, &#8216;&gt;&#8217;, &#8216;&gt;=&#8217;, &#8216;&lt;&#8217;, &#8216;&lt;=&#8217;, &#8216;LIKE&#8217;,  &#8216;NOT LIKE&#8217;, &#8216;IN&#8217;, &#8216;NOT IN&#8217;, &#8216;BETWEEN&#8217;, &#8216;NOT BETWEEN&#8217;. Default value is  &#8216;=&#8217;.</li>
<li> <strong><tt>type</tt></strong> (<em>string</em>) &#8211; Custom field type.  Possible values are &#8216;NUMERIC&#8217;, &#8216;BINARY&#8217;, &#8216;CHAR&#8217;, &#8216;DATE&#8217;, &#8216;DATETIME&#8217;,  &#8216;DECIMAL&#8217;, &#8216;SIGNED&#8217;, &#8216;TIME&#8217;, &#8216;UNSIGNED&#8217;. Default value is &#8216;CHAR&#8217;.</li>
</ul>
</li>
</ul>
<p><strong>Note</strong>: seems <tt>meta_query</tt> is supposed to be an <strong>array  of arrays</strong>: <a title="http://core.trac.wordpress.org/ticket/16563" href="http://core.trac.wordpress.org/ticket/16563">http://core.trac.wordpress.org/ticket/16563</a></p>
<p><strong>Simple Custom Field Query:</strong></p>
<p>Display posts where the custom field key is &#8216;color&#8217;, regardless  of the custom field value:</p>
<pre>$query = new WP_Query( 'meta_key=color' );</pre>
<p>Display posts where the custom field value is &#8216;blue&#8217;, regardless of  the custom field key:</p>
<pre>$query = new WP_Query( 'meta_value=blue' );</pre>
<p>Display <a title="Pages" href="http://codex.wordpress.org/Pages">Page</a> where the custom field value is &#8216;blue&#8217;, regardless of the custom field  key:</p>
<pre>$query = new WP_Query( 'meta_value=blue&amp;post_type=page' );</pre>
<p>Display posts where the custom field key is &#8216;color&#8217; and the custom  field value is &#8216;blue&#8217;:</p>
<pre>$query = new WP_Query( array( 'meta_key' =&gt; 'color', 'meta_value' =&gt; 'blue' ) );</pre>
<p>Display posts where the custom field key is &#8216;color&#8217; and the custom  field value IS NOT &#8216;blue&#8217;:</p>
<pre>$query = new WP_Query( array( 'meta_key' =&gt; 'color', 'meta_value' =&gt; 'blue', 'meta_compare' =&gt; '!=' ) );</pre>
<p>Display &#8216;product&#8217;(s) where the custom field key is &#8216;price&#8217; and the  custom field value that is LESS THAN OR EQUAL TO 22.  <em>Note the value  99 will be considered greater than 100 as the data is stored as  &#8217;strings&#8217;, not &#8216;numbers&#8217;.</em></p>
<pre>$query = new WP_Query( array( 'meta_key' =&gt; 'price', 'meta_value' =&gt; '22', 'meta_compare' =&gt; '&lt;=', 'post_type' =&gt; 'product' ) );</pre>
<p>Display posts with a custom field value of zero (0), regardless of  the custom field key:</p>
<pre>$query = new WP_Query( array ( 'meta_value' =&gt; '_wp_zero_value' ) );</pre>
<p><strong>Single Custom Field Handling:</strong></p>
<p>Display posts from a single custom field:</p>
<pre>$args = array(
	'post_type' =&gt; 'product',
	'meta_query' =&gt; array(
		array(
			'key' =&gt; 'color',
			'value' =&gt; 'blue',
			'compare' =&gt; 'NOT LIKE'
		)
	)
 );
$query = new WP_Query( $args );</pre>
<p><strong>Multiple Custom Field Handling:</strong></p>
<p>Display posts from several custom field:</p>
<pre>$args = array(
	'post_type' =&gt; 'product',
	'meta_query' =&gt; array(
		array(
			'key' =&gt; 'color',
			'value' =&gt; 'blue',
			'compare' =&gt; 'NOT LIKE'
		),
		array(
			'key' =&gt; 'price',
			'value' =&gt; array( 20, 100 ),
			'type' =&gt; 'numeric',
			'compare' =&gt; 'BETWEEN'
		)
	)
 );
$query = new WP_Query( $args );</pre>
<p><a id="Filters" name="Filters"></a></p>
<h2><span>Filters</span></h2>
<ul>
<li> <strong><tt><a title="Plugin API/Filter Reference/posts distinct" href="http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_distinct">posts_distinct</a></tt></strong> &#8211; Alters SQL &#8216;DISTINCTROW&#8217; clause to the query that returns the post  array.</li>
</ul>
<ul>
<li> <strong><tt><a title="Plugin API/Filter Reference/posts groupby (page does  not exist)" href="http://codex.wordpress.org/index.php?title=Plugin_API/Filter_Reference/posts_groupby&amp;action=edit&amp;redlink=1">posts_groupby</a></tt></strong> &#8211; Alters SQL &#8216;GROUP BY&#8217; clause  of the query that returns the post array.</li>
</ul>
<ul>
<li> <strong><tt><a title="Plugin API/Filter Reference/posts join (page does  not exist)" href="http://codex.wordpress.org/index.php?title=Plugin_API/Filter_Reference/posts_join&amp;action=edit&amp;redlink=1">posts_join</a></tt></strong> &#8211; Alters SQL &#8216;JOIN&#8217; clause of the  query that returns the post array.</li>
</ul>
<ul>
<li> <strong><tt><a title="Plugin API/Filter Reference/post limits (page does  not exist)" href="http://codex.wordpress.org/index.php?title=Plugin_API/Filter_Reference/post_limits&amp;action=edit&amp;redlink=1">post_limits</a></tt></strong> &#8211; Alters SQL &#8216;LIMIT&#8217; clause of the  query that returns the post array.</li>
</ul>
<ul>
<li> <strong><tt><a title="Plugin API/Filter Reference/posts orderby (page does  not exist)" href="http://codex.wordpress.org/index.php?title=Plugin_API/Filter_Reference/posts_orderby&amp;action=edit&amp;redlink=1">posts_orderby</a></tt></strong> &#8211; Alters SQL &#8216;ORDER BY&#8217; clause  of the query that returns the post array.</li>
</ul>
<ul>
<li> <strong><tt><a title="Plugin API/Filter Reference/posts where" href="http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where">posts_where</a></tt></strong> &#8211; Alters SQL &#8216;WHERE&#8217; clause of the query that returns the post array.</li>
</ul>
<ul>
<li> <strong><tt><a title="Plugin API/Filter Reference/posts join paged (page  does not exist)" href="http://codex.wordpress.org/index.php?title=Plugin_API/Filter_Reference/posts_join_paged&amp;action=edit&amp;redlink=1">posts_join_paged</a></tt></strong> &#8211; Alters SQL paging for  posts using &#8216;JOIN&#8217; clause of the query that returns the post array.</li>
</ul>
<ul>
<li> <strong><tt><a title="Plugin API/Filter Reference/posts where paged (page  does not exist)" href="http://codex.wordpress.org/index.php?title=Plugin_API/Filter_Reference/posts_where_paged&amp;action=edit&amp;redlink=1">posts_where_paged</a></tt></strong> &#8211; Alters SQL paging for  posts using &#8216;WHERE&#8217; clause of the query that returns the post array.</li>
</ul>
<ul>
<li> <strong><tt><a title="Plugin API/Filter Reference/posts clauses (page does  not exist)" href="http://codex.wordpress.org/index.php?title=Plugin_API/Filter_Reference/posts_clauses&amp;action=edit&amp;redlink=1">posts_clauses</a></tt></strong> (<strong>since WP 3.1</strong>) &#8211; Alters  all the SQL clauses above in one go.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.result-search.com/m/lyman/225.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ultimate Guide to Roles and Capabilities</title>
		<link>http://www.result-search.com/m/lyman/223.html</link>
		<comments>http://www.result-search.com/m/lyman/223.html#comments</comments>
		<pubDate>Fri, 15 Apr 2011 14:01:50 +0000</pubDate>
		<dc:creator>lyman</dc:creator>
				<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.result-search.com/m/?p=223</guid>
		<description><![CDATA[
Since Roles and  Capabilities are introduced in WordPress 2.0, the User Level approach has been declared deprecated. However, it’s disappointing that most  plugins and themes out there still use user levels to control access to  admin option pages and other functionalities. This guide shows you how  to properly use Roles and [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>Since <a href="http://codex.wordpress.org/Roles_and_Capabilities">Roles and  Capabilities</a> are introduced in WordPress 2.0, the <a href="http://codex.wordpress.org/User_Levels">User Level approach</a> has been declared deprecated. However, it’s disappointing that most  plugins and themes out there still use user levels to control access to  admin option pages and other functionalities. This guide shows you how  to properly use Roles and Capabilities in your plugins and themes.</p>
<p><strong>Note</strong>: This article is a long one, therefore you  should probably bookmark it so that you can always come back later for  reference.</p>
<p><span id="more-92"> </span></p>
<h2>Table of Contents</h2>
<ol>
<li><a href="#what">What  are Roles and Capabilities?</a></li>
<li><a href="#admin-options">Capabilities  and administration menus</a></li>
<li><a href="#check-capability">Checking  a user’s capability</a></li>
<li><a href="#add-role">Adding  custom user roles</a></li>
<li><a href="#add-capability">Adding  custom user capabilities</a></li>
<li><a href="#api">WordPress  Capability Classes</a></li>
</ol>
<h2 id="what">What are Roles and Capabilities?</h2>
<p>As in other CMS and web applications, WordPress has a built-in system  to verify whether a particular user has enough privilege to take a  certain action. Users are divided into Roles, and each Role is assigned  certain capabilities (or permissions). Here is a summary of <a href="http://codex.wordpress.org/Roles_and_Capabilities#Summary_of_Roles">WordPress  default roles</a>:</p>
<blockquote><p><strong>Administrator</strong> – Somebody who has access  to all the administration features</p>
<p><strong>Editor</strong> – Somebody who can publish posts, manage  posts as well as manage other people’s posts, etc.</p>
<p><strong>Author</strong> – Somebody who can publish and manage their  own posts</p>
<p><strong>Contributor</strong> – Somebody who can write and manage  their posts but not publish posts</p>
<p><strong>Subscriber</strong> – Somebody who can read  comments/comment/receive news letters, etc.</p></blockquote>
<p>This system of Roles and Capabilities is much more flexible than User  Level, since it enables you to add, remove or reassign capabilities  among roles. You can even add more roles to the system without  destroying the default setup.</p>
<h2 id="admin-options">Capabilities and administration menus</h2>
<p>Almost every plugin needs to have at least one page in the admin area  to let users customize how the plugin is used. In order to do this, you  need to <a href="http://codex.wordpress.org/Adding_Administration_Menus">add your  own administration menu items</a>. There are a bunch of WordPress  functions which let you do this:</p>
<div>
<div id="highlighter_565159">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10</div>
<div>11</div>
<div>12</div>
<div>13</div>
<div>14</div>
<div>15</div>
<div>16</div>
<div>17</div>
<div>18</div>
<div>19</div>
<div>20</div>
</td>
<td>
<div>
<div><code>// add top  level menu</code></div>
<div><code>add_menu_page(page_title, menu_title, capability,  handle, [</code><code>function</code><code>], [icon_url]);</code></div>
<div><code>// add sub-menu pages</code></div>
<div><code>add_submenu_page(parent,  page_title, menu_title, capability, file/handle, [</code><code>function</code><code>]);</code></div>
<div><code>// add Options sub-menu</code></div>
<div><code>add_options_page(page_title,  menu_title, capability, handle, [</code><code>function</code><code>]);</code></div>
<div><code>// add  Management sub-menu</code></div>
<div><code>add_management_page(page_title, menu_title,  capability, handle, [</code><code>function</code><code>]);</code></div>
<div><code>// add Pages sub-menu</code></div>
<div><code>add_pages_page( page_title,  menu_title, capability, handle, [</code><code>function</code><code>]);</code></div>
<div><code>// add Posts sub-menu</code></div>
<div><code>add_posts_page( page_title,  menu_title, capability, handle, [</code><code>function</code><code>]);</code></div>
<div><code>// add Appearances sub-menu</code></div>
<div><code>add_theme_page(  page_title, menu_title, capability, handle, [</code><code>function</code><code>]);</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>As you can see, there’s always a required parameter called <code>capability</code> for each of those functions. This essentially means the user who logs  in to the administration area needs to have a certain capability to see  the menu item.  You can either use a user level (which is deprecated and  not recommended), or a string representing a certain capability (for  example, <code>edit_posts</code>).</p>
<p>Many plugins still use user levels (numeric representation of a  user’s privilege, from 0 to 10). However, this is deprecated and should  not be used anymore. By using capabilities, you won’t have to worry when  user levels are not supported by WordPress, and if you want to add and  use your custom capabilities, this is the way to go.</p>
<p>If you use the functions above to add menu items to the admin area,  only the users who have the specified capability can see the menu items  and access the pages associated with those items. If your theme or  plugin has an option page, it’s important that you restrict access to  that page properly. For example, if it’s a theme option page, you should  use <code>edit_themes</code> capability, while if it’s a plugin option,  <code>edit_plugins</code>. Another way is to use <code>manage_options</code> for both plugin and theme option pages.</p>
<p>Remember, sometimes the blog administrator wants to share and divide  responsibilities among several other users. As a result, using  capabilities make your themes and plugins much more customizable.</p>
<h2 id="check-capability">Checking a user’s capability</h2>
<p>If your plugin or theme involves the user making changes to the  blog’s data (adding new or editing existing content etc.), it’s very  important that you check whether the current user has enough capability  to make a certain action. The <code>current_user_can()</code> function  lets you do this:</p>
<div>
<div id="highlighter_520022">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
</td>
<td>
<div>
<div><code>if</code> <code>(  current_user_can( </code><code>$capability</code> <code>) ) {</code></div>
<div><code> </code><code>//  do something if the current user has $capability</code></div>
<div><code>}</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>This function also accepts an optional argument for a certain post  ID, in case you want to check whether the current user can do something  to that post:</p>
<div>
<div id="highlighter_442654">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
</td>
<td>
<div>
<div><code>// check  whether the current can edit a post with the ID $post_id</code></div>
<div><code>current_user_can( </code><code>'edit_post'</code><code>, </code><code>$post_id</code> <code>);</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>There’s another function you can use to check whether the author of a  certain post has a certain capability:</p>
<div>
<div id="highlighter_275164">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
</td>
<td>
<div>
<div><code>if</code> <code>(  author_can( </code><code>$post</code><code>, </code><code>$capability</code> <code>) ) {</code></div>
<div><code> </code><code>// do something if the author of the post $post has  $capability</code></div>
<div><code>}</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>The first argument can be either a post object, or a post ID.  Although this function is rarely used, it’s helpful to know it’s there. I  personally never had to use that function, but if you have an  interesting example, let me know in the comment!</p>
<h2 id="add-roles">Adding custom user roles</h2>
<p>Sometimes it’s necessary for your plugin to add new roles to the  system. Let’s say you’re coding a new gallery plugin where users can  register to upload photos to your site, but that’s it – these registered  users can’t add or modify any other type of content to your blog (such  as posts or pages). The best way to do this, is to add a new custom  role:</p>
<div>
<div id="highlighter_799065">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</td>
<td>
<div>
<div><code>add_role( </code><code>$role_name</code><code>, </code><code>$display_name</code><code>, </code><code>$capabilities</code> <code>);</code></div>
<div><code>// for example:</code></div>
<div><code>add_role( </code><code>'photo_uploader'</code><code>, </code><code>'Photo Uploader'</code><code>, </code><code>array</code><code>( </code><code>'organize_gallery'</code> <code>) );</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>What this function does is add a new role to the system with a set of  capabilities. The example aboves add a role called “photo_uploader”,  with a display name and an array containing a list of default  capabilities for that role (in this case, <code>organize_gallery</code> ).</p>
<p>When you process a request to create, edit or upload galleries, you  should use <code>current_user_can()</code> to check whether the current  user are permitted to take these actions.</p>
<div>
<div id="highlighter_840378">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
</td>
<td>
<div>
<div><code>if</code> <code>(  current_user_can( </code><code>'organize_gallery'</code> <code>) ) {</code></div>
<div><code> </code><code>// do something</code></div>
<div><code>}</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>The users who are assigned this role can only <code>organize_gallery</code>,  but cannot <code>edit_posts</code> or <code>publish_posts</code>.</p>
<p>To remove a role, you can use <code>remove_role()</code>:</p>
<div>
<div id="highlighter_507107">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
</td>
<td>
<div>
<div><code>remove_role( </code><code>'photo_uploader'</code> <code>);</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>You should have an option somewhere for your plugin users to remove  this custom role when they decide to uninstall your plugin.</p>
<p>But what if you want to add capabilities to existing users?</p>
<h2 id="add-capability">Adding custom user capabilities</h2>
<p>This is useful when you develop a plugin that allows users to take  actions other than manipulating post contents. Let’s come back to our  gallery plugin example above. Say, if you also want to assign <code>organize_gallery</code> capability to existing roles (administrator, editor, author,  contributor etc. ), what would you do?</p>
<div>
<div id="highlighter_544618">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</td>
<td>
<div>
<div><code>// get the  "author" role object</code></div>
<div><code>$role</code> <code>= get_role( </code><code>'author'</code> <code>);</code></div>
<div><code>// add "organize_gallery" to this role  object</code></div>
<div><code>$role</code><code>-&gt;add_cap( </code><code>'organize_gallery'</code> <code>);</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h2 id="api">WordPress Capability Classes</h2>
<p>We’ve covered checking and adding capabilities, as well as adding  roles. These are the most frequent used functions for managing user  permissions in WordPress. However, as the title of this post contains  the word “ultimate”, I’d like to also cover the three WordPress classes  that work behind the scene and the API these classes provide, which you  can use for advanced permission management in your plugin. These three  classes are:</p>
<ul>
<li>WP_Roles</li>
<li>WP_Role</li>
<li>WP_User</li>
</ul>
<p>The source code of these three classes can be found in <code>wp-includes/capabilities.php</code>.  The source code is documented in great details and I’m sure you can  understand it easily, but I’d like to sum up what you can do with these  classes.</p>
<h3 id="wp_roles-class">The WP_Roles Class</h3>
<p>This class, as its name suggests, is for managing roles in general.  When you use it in your plugin, you actually don’t have to initiate a  new object, but use a global object which has been created by WordPress:</p>
<div>
<div id="highlighter_909991">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
</td>
<td>
<div>
<div><code>global</code> <code>$wp_roles</code><code>;</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>The <code>$wp_roles</code> is available as a global object, and can  be used anywhere in your functions, as long as it’s declared beforehand  in your functions with the <code>global</code> keyword.</p>
<p>As covered before, you can add and remove roles using <code>add_role()</code> and <code>remove_role()</code>. These functions are actually wrappers  for <code>$wp_roles-&gt;add_role()</code>, and <code>$wp_roles-&gt;remove_role</code>.  Therefore you can add and remove roles using the <code>$wp_roles</code> object as well:</p>
<div>
<div id="highlighter_953824">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
</td>
<td>
<div>
<div><code>global</code> <code>$wp_roles</code><code>;</code></div>
<div><code>// add a  new role, same arguments as add_role()</code></div>
<div><code>$wp_roles</code><code>-&gt;add_role( </code><code>$role</code><code>, </code><code>$display_name</code><code>, </code><code>$capabilities</code> <code>)</code></div>
<div><code>// remove a role, same arguments as remove_role()</code></div>
<div><code>$wp_roles</code><code>-&gt;remove_role( </code><code>$role</code> <code>);</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Likewise, you can also get a role using this method:</p>
<div>
<div id="highlighter_325958">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
</td>
<td>
<div>
<div><code>global</code> <code>$wp_roles</code><code>;</code></div>
<div><code>// get a  role based on role name, does the same thing as get_role()</code></div>
<div><code>$wp_roles</code><code>-&gt;get_role( </code><code>$role</code> <code>);</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>You can also get a list of available roles, containing pair of role  names and role display names. This is useful when you want to provide an  interface for the user to change capability assignment.</p>
<div>
<div id="highlighter_227082">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
</td>
<td>
<div>
<div><code>global</code> <code>$wp_roles</code><code>;</code></div>
<div><code>// get a  list of values, containing pairs of: $role_name =&gt; $display_name</code></div>
<div><code>$roles</code> <code>= </code><code>$wp_roles</code><code>-&gt;get_names();</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Finally, you can add and remove capabilities using <code>$wp_roles</code> too, making this object versatile for almost all roles and capabilities  operations.</p>
<div>
<div id="highlighter_43941">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10</div>
<div>11</div>
</td>
<td>
<div>
<div><code>global</code> <code>$wp_roles</code><code>;</code></div>
<div><code>// add capability $cap to role $role</code></div>
<div><code>$wp_roles</code><code>-&gt;add_cap( </code><code>$role</code><code>, </code><code>$cap</code> <code>);</code></div>
<div><code>// remove  capability $cap from role $role</code></div>
<div><code>$wp_roles</code><code>-&gt;remove_cap( </code><code>$role</code><code>, </code><code>$cap</code> <code>);</code></div>
<div><code>// for  example</code></div>
<div><code>$wp_roles</code><code>-&gt;add_cap( </code><code>'administrator'</code><code>, </code><code>'manage_galleries'</code> <code>);</code></div>
<div><code>$wp_roles</code><code>-&gt;remove_cap( </code><code>'subscriber'</code><code>, </code><code>'view_galleries'</code> <code>);</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3 id="wp_role-class">WP_Role Class</h3>
<p>This is a very simple class. All it does is adding and removing  capabilities.</p>
<div>
<div id="highlighter_303489">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
</td>
<td>
<div>
<div><code>// get the  the role object</code></div>
<div><code>$role_object</code> <code>=  get_role( </code><code>$role_name</code> <code>);</code></div>
<div><code>// add $cap  capability to this role object</code></div>
<div><code>$role_object</code><code>-&gt;add_cap( </code><code>$capability_name</code> <code>);</code></div>
<div><code>// remove $cap capability from this role object</code></div>
<div><code>$role_object</code><code>-&gt;remove_cap( </code><code>$capability_name</code> <code>);</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3 id="wp_user-class">WP_User class</h3>
<p>This class lets you manage roles and capabilities per user, which  means you can assign multiple roles to a particular user, or add a  capability to a certain user regardless of his current role.</p>
<p>First of all, you need to get the user object before manipulating its  roles and capabilities:</p>
<div>
<div id="highlighter_856960">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</td>
<td>
<div>
<div><code>// get user  by user ID</code></div>
<div><code>$user</code> <code>= </code><code>new</code> <code>WP_User( </code><code>$id</code> <code>);</code></div>
<div><code>// or get user by username</code></div>
<div><code>$user</code> <code>= </code><code>new</code> <code>WP_User( null, </code><code>$name</code> <code>);</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>As you can see, you can get a user object based on either his user ID  or username. With the latter, the first parameter must be empty (either  <code>null</code> or an empty string). Examples:</p>
<div>
<div id="highlighter_612801">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</td>
<td>
<div>
<div><code>// get the  administrator by ID</code></div>
<div><code>$admin</code> <code>= </code><code>new</code> <code>WP_User( 1 );</code></div>
<div><code>// get the administrator by username</code></div>
<div><code>$admin</code> <code>= </code><code>new</code> <code>WP_User( null, </code><code>'admin'</code> <code>);</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Once you have the user object, you can add another role to this user  without modifying his current role (which means the user can have as  many roles as you want):</p>
<div>
<div id="highlighter_712273">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
</td>
<td>
<div>
<div><code>$user</code><code>-&gt;add_role( </code><code>$role_name</code> <code>);</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Or you can remove a role from this user, using <code>remove_role()</code>:</p>
<div>
<div id="highlighter_925558">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
</td>
<td>
<div>
<div><code>$user</code><code>-&gt;remove_role( </code><code>$role_name</code> <code>);</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>You can also set a role to this user, which means removing all the  current roles of this user and assign a new one:</p>
<div>
<div id="highlighter_775609">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
</td>
<td>
<div>
<div><code>$user</code><code>-&gt;set_role( </code><code>$role_name</code> <code>);</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>For manipulating capabilities, you have a bunch of methods that allow  you to do various things:</p>
<div>
<div id="highlighter_176680">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10</div>
<div>11</div>
<div>12</div>
<div>13</div>
</td>
<td>
<div>
<div><code>// check whether the user has a certain capability or role  name</code></div>
<div><code>if</code> <code>( </code><code>$user</code><code>-&gt;has_cap( </code><code>$cap_name</code> <code>) ) {</code></div>
<div><code> </code><code>// do something</code></div>
<div><code>}</code></div>
<div><code>// add a capability to the user and  grant access to that capability</code></div>
<div><code>$user</code><code>-&gt;add_cap( </code><code>$cap_name</code> <code>);</code></div>
<div><code>// remove a  capability from the user</code></div>
<div><code>$user</code><code>-&gt;remove_cap( </code><code>$cap_name</code> <code>);</code></div>
<div><code>// remove  all capabilities from the user</code></div>
<div><code>$user</code><code>-&gt;remove_all_caps();</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3>Conclusion</h3>
<p>There, that’s all there is to know about Roles and Capabilities. You  might not need to grasp all of this, but it’s definitely helpful to know  WordPress has a full-fledged user and role management system, which you  can always use for complicated projects. This post has been all theory  so far, but in the next tutorial, I’ll show you how to use this  knowledge to build a “client login” area for your WordPress portfolio  site.</p>
<p>If you have any comment or suggestion, please leave it below!</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.result-search.com/m/lyman/223.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create a Comic Book Themed Web Design, Photoshop to HTML + CSS (Part 1)</title>
		<link>http://www.result-search.com/m/lyman/219.html</link>
		<comments>http://www.result-search.com/m/lyman/219.html#comments</comments>
		<pubDate>Wed, 13 Apr 2011 06:20:37 +0000</pubDate>
		<dc:creator>lyman</dc:creator>
				<category><![CDATA[design]]></category>

		<guid isPermaLink="false">http://www.result-search.com/m/?p=219</guid>
		<description><![CDATA[
Final Product What You&#8217;ll Be Creating




Download Source Files


Updated with the Coding Tut! This time I’ve  got for you a fun tutorial for everyone. In Part 1 we will create a  very original design for all the comicbook fans out there. We will  create this blog layout from scratch using several tricks in [...]]]></description>
			<content:encoded><![CDATA[<div>
<h3>Final Product <span>What You&#8217;ll Be Creating</span></h3>
<div><a title="Click for Large Image" rel="external" href="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/final-image.jpg" target="blank"><img src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/click.jpg" alt="" /></a></div>
</div>
<div style="padding-top: 40px;">
<div>
<div style="margin-left: 100px;"><a rel="external" href="http://webdesigntutsplus.s3.amazonaws.com/109_Comcastic/comicastic.zip" target="blank"><span>Download</span> <small>Source Files</small></a></div>
</div>
<p><script type="text/javascript"></script><br />
<strong>Updated with the Coding Tut! </strong>This time I’ve  got for you a fun tutorial for everyone. In Part 1 we will create a  very original design for all the comicbook fans out there. We will  create this blog layout from scratch using several tricks in Photoshop  to make it look awesome. Then in Part 2 we will learn how to slice it,  code it, and get it ready to be converted into a blog CMS theme. Are you  ready?<span id="more-2439"> </span></p>
<hr />
<h2>The Coding Phase is Available</h2>
<p>The<a href="http://net.tutsplus.com/tutorials/site-builds/create-a-comic-book-themed-web-design-photoshop-to-html-css-part-2/"> coding phase of the tutorial </a>(Part 2) is now available over at our  sister site, <a href="http://net.tutsplus.com/">Nettuts</a>! When you’re  finished with this design phase, head on over to <a href="http://net.tutsplus.com/">Nettuts</a> to slice and code it in  HTML/CSS. Thanks for all of the feedback and requests for the followup  everyone!</p>
<hr />
<h2>Before Getting Started</h2>
<p>Let’s get it started! In order to speed up the reading I will avoid  some of the most basic explanations (like how to create a layer mask or  how to edit the handlers or Beziers of a vector shape). You will need  some basic knowledge about Layers, Guides, Vector and Layer Masks,  Brushes, the Pen Tool, and working with Typography (Character and  Paragraphs).</p>
<p>The assets for this tutorial are:</p>
<ul>
<li>The Paper Texture – <a href="http://www.sxc.hu/photo/1318914">Scraps</a></li>
<li><a href="http://myphotoshopbrushes.com/custom_shapes/id/2002">Sunburst  Shapes</a></li>
<li>Comic fonts from Font Squirrel (<a href="http://www.fontsquirrel.com/fonts/Komika-Title">Komika  Title</a> and <a href="http://www.fontsquirrel.com/fonts/Komika-Text">Komika  Text</a>)</li>
<li><a href="http://www.komodomedia.com/blog/2009/06/social-network-icon-pack/">Social  Media Icon Pack</a> by <a href="http://www.komodomedia.com/">Komodo  Media</a></li>
</ul>
<p>The first step is creating a mock up, doodle, or even just a sketch  the layout on a napkin. Having a rough draft of the site’s structure  makes easy placing the elements on the design. Below you will see a  simple sketch showing the following elements:</p>
<p>A header, with the logo, search bar and social media links, besides  the main navigation bar.<br />
 A banner, with featured posts, notice how the post text is placed over  the image into a talk bubble to depict the &#8220;comic&#8221; style.<br />
 A content area, with a list of posts displayed in two columns, each post  have a picture associated and the text is shown into a talk bubble as  well.<br />
 A footer, with a list of the blog’s categories, archive and popular post  and recent comments and the copyright information.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/0.jpg" border="0" alt="" /></div>
<h2><span>Step 1</span>: Setting Up the Document</h2>
<p>Open Photoshop, download the 12 columns Photoshop template from <a href="http://www.960.gs/"> 960 Grid System</a> or create a new document 960px with and make draw  some Guides to the left and right borders.</p>
<p>Increase the working area to see how it looks on wider resolutions  and increase the height as well. I’m setting the document dimensions to  1420px width and 1200px height. Finally go to Layer &gt; New Fill Layer  &gt; Solid Color… and set a Black (#000000) background for the canvas.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/1.jpg" border="0" alt="" /></div>
<h2><span>Step 2</span>: Header Background</h2>
<p>Draw a horizontal Guide around 450px from the top border, we will use  it as a reference guide to add a shade on top of the page. Using the  Rectangle tool, draw a wide rectangle using this color as foreground  (#AA0001). Then apply a Gradient Layer Mask (Black to White) to the  rectangle in order to hide the bottom part of it.<br />
 <em>Tip: do not ever use a Gradient Layer for backgrounds, because when  increasing the height of the canvas (a very common practice in web  design) the background gets distorted.</em></p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/2.jpg" border="0" alt="" /></div>
<h2><span>Step 1</span>: Add a Texture to theBackground</h2>
<p>Open the &#8220;Paper Texture&#8221; from the assets Copy and Paste it above the  red gradient layer. Scale it in order to make it fit into the bounds of  the design and change the layer’s Blending Mode to Linear Burn. We will  slice this as a large image background, but for wider resolutions we  need to subtle merging the edges of the paper with the black background,  for this, using the Burn Tool, darken the areas close to the Left and  Right edges of our paper texture. You can use a big and soft Brush (0%  Hardness).</p>
<p>Always keep your layers organized, put both layers (&#8221;Paper&#8221; and  &#8220;Rectangle&#8221;) into a folder named &#8220;Header Bg&#8221;.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/3.jpg" border="0" alt="" /></div>
<h2><span>Step 1</span>: Sunbursts</h2>
<p>Moving forward with the comic style, let’s add some sunburst stripes  to create a dramatic background for the logo.</p>
<p>Open the &#8220;Sunburst&#8221; shapes from the assets. On the Custom Shape tool,  choose your favorite sunburst shape an draw it over the red gradient  layer. Place the shape to near to the left border of the 960 template  (show the Guides to see the bounds). Apply to the &#8220;Sunburst&#8221; layer a  Radial Gradient Layer Mask (white in the center and black in the  outside). Change the Layer Opacity to 50%. Optional: using an irregular  Brush, paint with Black over the Layer Mask to create a more grunge  merge between the sunburst and the background.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/4.jpg" border="0" alt="" /></div>
<h2><span>Step 1</span>: Halftone</h2>
<p>In order to enforce the comic style, we will add some Halftone points  over the header background. Create a new layer above the &#8220;Sunburst&#8221;  layer, and render some Black and White Clouds in there (Filter &gt;  Render &gt; Clouds). Then go to Filter &gt; Pixelate &gt; Color  Halftone. Change the &#8220;Halftone&#8221; layer’s Blending Mode to Multiply and  add a Layer Mask &gt; Hide All to it. Then using a big and soft Brush  (Color: White and Opacity and Flow to 75%) paint some areas of the layer  mask to make visible only a bit of the halftone pattern.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/5.jpg" border="0" alt="" /></div>
<h2><span>Step 1</span>: The Title</h2>
<p>Now you have the header background finished, let’s add the Logo.  First draw a reference Guide around 180 px below the top border, the  logo shouldn’t be below that guide. Using the &#8220;Komika Title&#8221; font face  from the assets type the title of the site (&#8221;Comicastic&#8221;) Font Size:  68pt and foreground color: #FFB401. Then Add more text element, like the  exclamation sign or the slogan in white (font size 16pt).</p>
<p>Then using the Free Transform Tool rotate the text a few degrees left  to make it look less formal. Try to get something like the image below,  but remember not to place any element below the guide. Finally put all  these layers into a folder labeled &#8220;Logo&#8221;.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/6.jpg" border="0" alt="" /></div>
<h2><span>Step 7</span>: Logo Layer Styles</h2>
<p>Add a Layer Style &gt; Gradient Overlay (#EA9403 – #FFC501) a Stroke  (Size:1px, Inside, #FCB600) and a Drop Shadow (Black, 50% Opacity,  Distance and Size: 2px) to the &#8220;logo&#8221; layer. Use a similar Style to the  slogan, but change the colors of the Gradient Overlay to #EDEDED -  #FFFFFF and the Stroke to White (#FFFFFF). If you place the exclamation  sign to the logo, you can try converting it into a shape (Layer &gt;  Type &gt; Convert to shape) and distorting it a bit as shows the bottom  of the image below.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/7.jpg" border="0" alt="" /></div>
<h2>Featured Posts Banner</h2>
<h2><span>Step 8</span>: Background</h2>
<p>Use the Rounded Rectangle Tool (Radius 5px) to draw a wide rectangle  all across the banner below the logo as shows the image below, the  height if the rectangle is up to you, I’m setting 250px. Then apply a  Gradient Overlay (Colors: #DA7E00 – #F0AD00, Angle: 90°) and Stroke  (Color: #F2AA00, Size: 1px, Position: Inside).Layer Styles to it.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/8.jpg" border="0" alt="" /></div>
<h2><span>Step 9</span>: Changing the  Top Banner</h2>
<p>Using the Direct Selection Tool (A) over our brand new rounded  rectangle, grab the points of the top left corner and move them to the  right (you can use the cursors for an accurate move). Then move the  bottom right points a few pixels left.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/9.jpg" border="0" alt="" /></div>
<h2><span>Step 10</span>: Adding the sliding picture container</h2>
<p>Now, using the Rectangle Tool draw a gray rectangle inside the yellow  banner (630px x 250px aprox.), you can leave the bottom part of the  gray rectangle a few pixels away to the bottom of the yellow banner to  create an out-of-bounds effect. Add a Stroke (Size: 1px, Position:  Inside, Color: #FFFFFF) and a Drop Shadow (Color: #000000, Opacity:50%,  Distance: 0px, Spread: 0px, Size: 5px) and try to place the rectangle as  shows the image below. Finally, put both layers (Gray and Yellow  rectangles) into a folder named &#8221;Top Banner&#8221;.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/10.jpg" border="0" alt="" /></div>
<h2><span>Step 11</span>: Main Navigation</h2>
<p>Using the font family &#8220;Komika Text&#8221; type the pages navigation at the  top right of the top banner, set the font Size to 18px and color:  #FFFFFF. Put it on a folder named &#8220;Pages Navigation&#8221;, be sure this  folder is behind the &#8220;Top Banner&#8221;. Then using the Rounded Rectangle Tool  (Radius: 3px, Color: #EFA800), draw a rectangle just behind the first  word of the navigation, name the layer &#8220;Selected Tab&#8221;. Next using the  Direct Selection Tool (A) move the points of the bottom left as shows  the image below. Next apply a Gradient Overlay to the &#8220;Selected Tab&#8221;  layer (Colors: #F0A900 – #FEBF00, Angle: 90°). If you want to, you can  add a very subtle Drop Shadow (Color: #000000, Opacity: 25%) to the  navigation text.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/11.jpg" border="0" alt="" /></div>
<h2><span>Step 12</span>: Add the banner images</h2>
<p>To show an actual sample, paste any image over the banner. If the  image is bigger that the rectangle you can use a Clipping Mask, for this  paste the image above the gray rectangle, then Option / Alt – Click  between the two layers, this will clip the image inside the rectangle no  cropping needed.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/12.jpg" border="0" alt="" /></div>
<h2><span>Step 13</span>: Banner Controls</h2>
<p>Select the Custom Shape Tool and chose one of the arrows, and draw a  couple one next to the other, both pointing left. Then Apply to both a  Gradient Overlay (#6D0004 – #980000) and a Stroke (Size: 1px, Position:  Inside, Color: #B20002). Put both arrows into a folder named &#8220;Prev&#8221; and  using the Free Transform Controls and holding the Command / Ctrl key,  distort the arrows a little bit. Then duplicate the folder and rename it  to &#8220;Next&#8221;, move it to the right of the banner and go to Edit &gt;  Transform &gt; Flip Horizontal to change its direction. Finally put both  folders &#8220;Next&#8221; and &#8220;Prev&#8221; into a new folder named &#8220;Controls&#8221;.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/13.jpg" border="0" alt="" /></div>
<h2><span>Step 14</span>: Controls Hover</h2>
<p>Now duplicate the &#8220;Next&#8221; and &#8220;Prev&#8221; folders and apply a different  layer style to the arrows in order to create a hover effect for each  one. I’m Copying the Layer Style from the exclamation sing of the title.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/14.jpg" border="0" alt="" /></div>
<h2><span>Step 15</span>: Halftone details</h2>
<p>With the same process of Step 5, create a Halftone Layer above the  yellow banner. With the &#8220;Halftone&#8221; layer selected do Command / Ctrl –  Click over the yellow banner, then hit Command / Ctrl + Shift + I to  invert the selection, then delete the exceeding. Change &#8220;Halftone&#8221;  layer’s Blending Mode to Overlay and Opacity to 25%. Finally add a Layer  Mask &gt; Hide All and using a big soft White Brush, paint over some  areas on the layer mask to make visible only a few portions of the  pattern.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/15.jpg" border="0" alt="" /></div>
<h2><span>Step 16</span>: Featured Article Talking Bubble</h2>
<p>Now is time to add a field to put the featured post’s content. For  this, using the Custom Shape Tool look for the Rounded Cornered and  Rectangular talking bubble. Draw it over the &#8220;Featured Image&#8221; Banner and  place it on the right as shows the image below. Before designing any of  this features you need to do some research if it’s possible to achieve  this kind of effect, even if you don’t know how to code, you can look  for some existing libraries of Ajax (JQuery / MooTools) and see what is  already done and working, and then adapt your design to an existing  library.</p>
<p>Then, using the Direct Selection Tool (A) distort the shape of the  bubble a little bit. Finally apply a Drop Shadow (Color: #000000,  Opacity: 25%, Distance: 5px, Spread: 0px, Size: 10px).</p>
<div><script type="text/javascript"></script> <script type="text/javascript"></script><ins style="display: inline-table; border: medium none; height: 250px; margin: 0pt; padding: 0pt; position: relative; visibility: visible; width: 300px;"><ins id="aswift_0_anchor" style="display: block; border: medium none; height: 250px; margin: 0pt; padding: 0pt; position: relative; visibility: visible; width: 300px;"></ins></ins></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/16.jpg" border="0" alt="" /></div>
<h2><span>Step 17</span>: Featured Post Text</h2>
<p>It’s time to add the title and a brief to our featured post. For the  title use &#8220;Komika Title&#8221;, 18pt. #680001. For the Body text, use &#8220;Komika  Text Tight&#8221;, Size: 16pt, Color: #1B1B1B. Place the text layers right  aligned as shown on the image below.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/17.jpg" border="0" alt="" /></div>
<h2><span>Step 18</span>: Comments Box and Post Meta</h2>
<p>Now, add another bubble, but smaller this time, use this color as  foreground: #9C0001 and add a Stroke layer style (Color: #D00000, Size:  1px, Position: Inside), just as shows the image below, then add the  comments number with &#8220;Komika Title&#8221; font face, Color: #FFFFFF and Size:  24pt. And the word &#8220;Comments&#8221; with &#8220;Komika Title&#8221;, Size: 12pt, Color:  #FFB301.</p>
<p>Finally add a small Meta (information about the post) below the post  brief with &#8220;Tahoma&#8221; font, Size: 10pt, Color: #1B1B1B. If there’s no  enough space to put the Meta text, you can use the Direct Selection Tool  to increase the height of the featured post bubble box a little bit.</p>
<p><em>Tip: Do not ever transform a Vector Rounded Corner element using  the Free Transform Tool in Photoshop, this will distort the corner,  select the points you want to move using the Direct Selection Tool and  then displace them.</em></p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/18.jpg" border="0" alt="" /></div>
<h2><span>Step 19</span>: Featured Post Title’s background</h2>
<p>Duplicate the featured post background bubble, hide the drop shadow,  change the fill color to yellow (#FFC001) and rasterize it. Then, using  the Rectangular Marquee Selection Tool, select all the yellow bubble  below the title line, then Delete the selection. Next, add a line of  border, with the &#8220;Bubble Title&#8221; layer selected, Command / Ctrl – Click  over the &#8220;Bubble Background&#8221; Vector mask. Then Go to Edit &gt; Modify  &gt; Contract and set the value to 1px. Finally, hit Command / Ctrl +  Shift + I to invert the selection and delete it.</p>
<p>This is a good time to set everything related to the top banner  organized into folders and add more detail if you want to, I’m adding a  yellow line between the Post brief and the Meta.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/19.jpg" border="0" alt="" /></div>
<h2>Main Content</h2>
<h2><span>Step 20</span>: Content Background</h2>
<p>Now let’s move forward with the main content background, create a  Folder named &#8220;Page Content&#8221; and draw a white (#FFFFFF) Rounded Corner  Rectangle (5 px radius) several pixels height (If the original canvas  size becomes too small at this time you can increase its size, just  ensure to keep the top border as is).</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/20.jpg" border="0" alt="" /></div>
<h2><span>Step 21</span>: Post Image</h2>
<p>It’s time to start adding content to the page, as default on blogs we  will design a list of the latest posts.</p>
<p>Draw two squares (3 columns width aprox.) and place them as shows the  image below. Doing the same process than step 12 add some images over  the squares using them as Clipping Masks. Finally select the square and  add a Stroke Layer Style to it (Color: #FFB801, Size: 1px, Position:  Inside).</p>
<p>We will work over one of this images adding the content around it,  and then duplicate it as many times as post want to show on the  homepage.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/21.jpg" border="0" alt="" /></div>
<h2><span>Step 22</span>: Add posts’ Titles and Categories.</h2>
<p>Draw two wide rectangles, one yellow (#F2AA00) and another White with  yellow border below (#FFB401). Over the yellow stripe, type the title  of the post using &#8220;Komika Title&#8221;, Color: #670003, Size: 18pt. And on the  white stripe, type the Categories names using &#8220;Komika Text Tight&#8221; Size:  13pt, Colors #212121 for links and #670003 when mouse over.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/22.jpg" border="0" alt="" /></div>
<h2><span>Step 23</span>: Post brief and Meta</h2>
<p>Draw a talking bubble again, over the picture and the yellow stripe,  fill it with this Color: #333333 with a 1px Stroke (Color: #696969) and  also apply the Drop shadow we did before on the banner. Then add the a  sample brief text using &#8220;Komika Text Tight&#8221; Size: 14pt, Color: #FFFFFF,   a sample Meta text using &#8220;Tahoma&#8221; 10pt Color #979797 and if you want to  a line between both texts (#4B4B4B).</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/23.jpg" border="0" alt="" /></div>
<h2><span>Step 24</span>: Finishing the main content</h2>
<p>To finish this part add a Comments bubble, basically repeating the  process of Step 18. Then put everything on folders, I’m naming the post  folder &#8220;A post&#8221;. Then, duplicate it (Command / Ctrl + Drag) and place it  on the right. Repeat the process with two or three rows of post as  shown at the bottom of the image below. Increase the height of the white  background as needed to fit all the post in.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/24.jpg" border="0" alt="" /></div>
<h2><span>Step 25</span>: Page Content Corner</h2>
<p>To increase the &#8220;comic book&#8221; style, we will add a simple page curl at  the bottom right of the white background.</p>
<p>First draw a Black Triangle at the bottom right corner (you can use  the Pen Tool), then duplicate it and move the triangle making it a  &#8220;reflex&#8221; of the black one, you can fill this copy with any other color.  Next warp the second triangle making it a little curve. Then, apply to  the warped triangle a Gradient Overlay using a nice mix of colors:  (#9C0001 – #FE0000 – #9C0001) and change the Angle to anything that  looks good according the angle of the curl, in this case 108 degrees.  Next using a Soft Brush (Black, Opacity and Flow 50%) paint some shadows  in a new layer behind the warped triangle. If you want to, add some  points to the warped triangle in order to add a rounded corner to the  tip just as shows the bottom of the image below. Finally, put all the  curl related layers into a folder named &#8220;Page Curl&#8221;. Keep it handy  because we are using it later.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/25.jpg" border="0" alt="" /></div>
<h2><span>Step 26</span>: Footer Background</h2>
<p>We are almost done, first create a folder named &#8220;Footer&#8221; and ensure  is below the &#8220;Page Content&#8221; folder, inside it draw a red (#9C0001)  circle, then apply a Gaussian Blur of at least 65px radius. Then  transform the resultant blurred circle to make it match with the  bounding guides.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/26.jpg" border="0" alt="" /></div>
<h2><span>Step 27</span>: Background sunbursts</h2>
<p>Now, with the Custom Shape Tool, select one of the Sunburst shapes  and draw a black one in the middle, then down its Opacity to 50%. Then  add the Halftone Pattern over the red glowing circle, hide it using a  layer mask and show only some parts of it. Finally down the opacity of  the red circle to 50%..</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/27.jpg" border="0" alt="" /></div>
<h2><span>Step 28</span>: Footer content background</h2>
<p>We will add common elements of a blog such Categories and Archive on  the footer.</p>
<p>Now, let’s add a background for the footer elements, draw a Rounded  Rectangle (5px radius) Color:#1A1A1A and set its Fill value to 50%,  making it around 3 columns wide. you can create copies of it to make fit  4 boxes at the footer.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/28.jpg" border="0" alt="" /></div>
<h2><span>Step 29</span>: Footer content background – Curl</h2>
<p>Select the first rectangle, (you can delete the others at this  point). Then duplicate the &#8220;Page Curl&#8221; folder and place it inside the  &#8220;Footer&#8221; folder, transform it to make it match with the bottom right  corner of the rectangle, then change the colors of the gradient to  different tones of gray. Finally add to the rectangle layer a Stroke  style (1px, Inside, #242424).</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/29.jpg" border="0" alt="" /></div>
<h2><span>Step 30</span>: Categories</h2>
<p>Now, add the title of the section, in this case &#8220;Categories&#8221; using  &#8220;Komika Title&#8221;, Size: 14px Color: #F2AA00. Use guides to delimit the  title baseline, keep it at least 20 px below the end of the page content  background. Then add some rows as sample categories, using &#8220;Komika Text  Tight&#8221;, Size: 16px, Color: #FFFFFF, and Red (#EC000A) as hover effect.  As an additional detail for the hover effect, add a little yellow  (#FFB301) arrow using the Custom Shape Tool. Put all the layers into a  folder named &#8220;Footer Element&#8221;.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/30.jpg" border="0" alt="" /></div>
<h2><span>Step 31</span>: Duplicate the footer section</h2>
<p>Duplicate the &#8220;Footer element&#8221; folder and move it to the right,  change the words to depict &#8220;Archives&#8221; this time.</p>
<p>Then duplicate the folder again but this time expand the translucent  background to make it twice wider, on top, type the titles for &#8220;Popular  Posts&#8221;, &#8220;Latest Posts&#8221; and &#8220;Recent Comments&#8221;, use yellow for the first  one and gray for the other two. As you guess, this will have a similar  functionality than a tabbed pane. Then add a little yellow triangle to  mark the selected tab.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/31.jpg" border="0" alt="" /></div>
<h2><span>Step 32</span>: Tabbed pane content</h2>
<p>Since this part will have mostly lists of posts, lets add them,  basically is a combination of &#8220;Komika Title&#8221; and &#8220;Komika Text Tight&#8221;  with different colors (See the screenshot below). The first row will be a  sample of the selected (hover) item, on this, add a black (#000000)  rounded rectangle behind the text and add a Horizontal Gradient (Black  to White) Layer Mask.</p>
<p>Finally, add a little Pager at the bottom of this section.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/32.jpg" border="0" alt="" /></div>
<h2><span>Step 33</span>: Search Bar</h2>
<p>It’s time to add some details to finish up our graphic. Let’s start  with the search bar. Create a folder named &#8220;Search Bar&#8221; on top of  everything, create a Rounded Rectangle (3px Radius, Color: #000000 with a  Stroke Effect Size: 1px, Position: Inside, Color: #7C0000) as the  search input, and a small rectangle for the search button; Copy  the  Layer Style of the selected item on the main navigation and paste it to  the search button. For the actual button, type the word &#8220;Go!&#8221; over it  with White, and apply the same Drop Shadow than the main navigation text  (recycling layer styles is a great time saver). On the Search input,  type the Word &#8220;Looking for something&#8221; using &#8220;Komika Text Tight&#8221; Color:  #F9A600.</p>
<p>Then add a Rectangle behind all the layers inside &#8220;Search Bar&#8221;, fill  it with a dark red #380001 (Fill: 50%) and apply a Stroke using this  Color: #890101. Convert it to a Smart Object and apply a Layer Mask &gt;  Hide All to it, fill the mask with a Reflected Black – White Gradient  to create the effect show at the bottom of the image below.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/33.jpg" border="0" alt="" /></div>
<h2><span>Step 34</span>: Social Media Icons</h2>
<p>Repeat the process of the search bar background but this time using a  less height bar and with a sightly different Stroke color (#860001).  Then type the word &#8220;Follow us&#8221; using &#8220;Komika title&#8221; and paste all the  icons you want to add, you can use the mini icons from the assets. Don’t  forget to keep your layers organized under folders.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/34.jpg" border="0" alt="" /></div>
<h2><span>Step 35</span>: Footer navigation and copyright information</h2>
<p>Finishing today’s work, let’s add the Footer navigation. Delimit the  section with a white Line, masked with a reflected black – white  gradient. Type the navigation links using Arial, Size 10px, Color:  #515151 and highlight a hover effect with yellow: #F2AA00. Then add the  copyright text Right aligned.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/35.jpg" border="0" alt="" /></div>
<h2><span>Step 36</span>: This is it!</h2>
<p>Finally double check all the layers are on its respective folder.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/36.jpg" border="0" alt="" /></div>
<h2>Conclusion</h2>
<p>We finished the graphic part of the process, now it’s time to jump  over NetTuts+ to see how to slice this and turn it to HTML+CSS, are you  ready?</p>
<div>.<img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/109_Comcastic/final.jpg" border="0" alt="" width="600" height="781" /></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.result-search.com/m/lyman/219.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Design An Innovative Portfolio Site Using Alternative UI/UX</title>
		<link>http://www.result-search.com/m/lyman/217.html</link>
		<comments>http://www.result-search.com/m/lyman/217.html#comments</comments>
		<pubDate>Wed, 13 Apr 2011 06:20:14 +0000</pubDate>
		<dc:creator>lyman</dc:creator>
				<category><![CDATA[design]]></category>

		<guid isPermaLink="false">http://www.result-search.com/m/?p=217</guid>
		<description><![CDATA[
Final Product What You&#8217;ll Be Creating




Demo View It Online


What’s the number one thing you want your portfolio site to  do? Stand out! Today, Paul J Noble is going to walk us through the  creation of his own uniquely designed portfolio site. He’ll show us  tips and tricks in Adobe Photoshop, as well [...]]]></description>
			<content:encoded><![CDATA[<div>
<h3>Final Product <span>What You&#8217;ll Be Creating</span></h3>
<div><a title="Click for Large Image" rel="external" href="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/paulnoble_final.jpg" target="blank"><img src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/final-product.jpg" alt="" /></a></div>
</div>
<div style="padding-top: 40px;">
<div>
<div style="margin-left: 120px;"><a rel="external" href="http://pauljnoble.com/index" target="blank"><span>Demo</span> <small>View It Online</small></a></div>
</div>
<p><script type="text/javascript"></script><br />
What’s the number one thing you want your portfolio site to  do? Stand out! Today, Paul J Noble is going to walk us through the  creation of his own <a href="http://pauljnoble.com/index" target="_blank">uniquely designed portfolio site</a>. He’ll show us  tips and tricks in Adobe Photoshop, as well as some clever approaches to  standing out from the pack of other portfolio sites.<span id="more-2521"> </span></p>
<hr />
<h2>Creating a Memorable Portfolio Site</h2>
<p>Think of your portfolio site is your online spokesperson to potential  clients. If done properly, it should tell people what you do, show off  your best work, and give them the opportunity to get in contact with  you. That’s all pretty obvious stuff – so what’s the difference between  an ordinary portfolio site and a truly remarkable one?</p>
<p>The key to an effective portfolio site isn’t just having great  projects – <em>it’s leaving a lasting impression on visitors</em>. Sure,  this might mean having incredible illustrations if you are a graphic  designer – but for web designers and developers, this often means  needing to push the boundaries of UI/UX and coding in order to show off  our strongest points.</p>
<p>In this tutorial, Paul J Noble is going to show us how he used some  simple, but remarkably innovative approaches to the UI/UX on his own  site to create a portfolio site that stretches the user’s expectations  using interactivity and subtle lighting effects.</p>
<p>Let’s dive in!</p>
<hr />
<h2><span>Step 1</span> The Canvas</h2>
<p>Create a new document in Photoshop that’s 1400 x 900. The final, HTML  rendered site will feature ‘liquid’ (i.e. scalable) elements so we’ll  need to keep in mind that the final design will not be a fixed size.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-01.jpg" border="0" alt="" /></div>
<hr />
<h2><span>Step 2</span> Lay the Foundation</h2>
<p>Creating a solid background is an easy way to get things started. For  this design we’re going to be using a base color<br />
 that’s dark enough to accentuate foreground images while also  offsetting pure black that may appear in the folio images. We’ll also  use include some blue to create a ‘cool’ dark color that will integrate  with the interface elements.</p>
<p>Select Layer &gt; New Fill Layer &gt; Solid Color and assign the  color #252a3b.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-02.jpg" border="0" alt="" /></div>
<hr />
<h2><span>Step 3</span> Laying the Guidelines</h2>
<p>As we’re using a scalable layout, we need to define the minimum  horizontal width. For most commercial sites this is around 1000 pixels  to accommodate users with 1024×768 resolution displays. However for this  site we’ll aim for 1100 pixels as a minimum width.</p>
<p>Firstly, make sure your guide units are set to pixels. This can be  set by going to Preferences &gt; Units &amp; Guides.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-03-01.jpg" border="0" alt="" /></div>
<p>Then, go to View &gt; New Guide. As we’re going to put our content in  the center and we’re aiming for a total minimum width of 1100 pixels,  we should place vertical guides at 150px and 1250px.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-03-02.jpg" border="0" alt="" /></div>
<hr />
<h2><span>Step 4</span> Create the Texture Pattern</h2>
<p>Subtle diagonal striping will help lift the design by creating a  separation between the foreground portfolio items and textured  background.</p>
<p>To achieve this we will apply a Pattern fill layer. However, first we  must create the pattern.</p>
<p>Create a new document 12×12 pixels with a transparent background and  add a new fill layer with a black fill (#000000).</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-04.jpg" border="0" alt="" /></div>
<p>Now, add a new layer (Layer &gt; New &gt; Layer). Using the pencil  tool with a brush size of 1px, draw three lines exactly as they appear  in the image below.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-04-05.jpg" border="0" alt="" /></div>
<p>Turn off the fill layer and set the lines layer opacity to 6%. To  save this as our pattern select Edit &gt; Define Pattern.</p>
<p>Returning to our original canvas, create a new layer with the texture  by selecting Layer &gt; New Fill Layer &gt; Pattern and select the  previously defined pattern.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-04-03.jpg" border="0" alt="" /></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-04-02.jpg" border="0" alt="" /></div>
<hr />
<h2><span>Step 5 </span> Navigation</h2>
<p>Now that we’ve created our base we can drop some flat layers that  comprise the major elements of the site</p>
<p>First, our navigation. As this site will be designed to have no  vertical scrolling we can position the navigation to align to the bottom  of the screen.</p>
<p>Create a new Group in the layers palette and label this group  ‘Navigation’.</p>
<p>Then create a new layer using the Rectangle Tool (U). With the Info  window open, draw this shape so it’s 1400×61 (the full width of the  document window and 61 pixels high). Align this layer at the bottom of  the document window.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-05-01.jpg" border="0" alt="" /></div>
<p>Now, apply a gradient to the layer by right-clicking the shape layer  in the Layers palette and selecting Blending Options then checking  Gradient Overlay (alternatively, select Layer &gt; Layer Style &gt;  Gradient Overlay).</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-05-02.jpg" border="0" alt="" /></div>
<p>In the Graident Editor, click the bottom color selector to open the  Color Picker. For the left color (bottom of the shape) use #2f313a. For  the right color (top of shape) use #3c3f49.</p>
<p>Next, create a new layer and lable this ‘highlight’. Using the Pencil  tool with a 1px brush and color #ffffff, draw a line while holding  shift across the top of the rectangle shape previously created. Then set  this layer’s opacity to 6%.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-05-03.jpg" border="0" alt="" /></div>
<hr />
<h2><span>Step 6 </span> The Logotype</h2>
<p>Create a new text layer 20 pixels from the left side of the document  and align the text to be vertically centred on the navigation rectangle  layer.</p>
<p>In this example the font DIN Light has been applied at 14px with a  loose tracking of 200. To create a shift between two parts of the logo  type two colors are used. For the first part #dddddd and the second,  darker part #737375.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-06-01.jpg" border="0" alt="" /></div>
<p>Next, add a subtle drop shadow to create the appearance of the text  being inset to the background. Select Layer &gt; Layer Style &gt; Drop  Shadow.</p>
<p>Unselect ‘Use Global Light’, change the direction to -45 degrees,  set size to 0px, distance 1px and opacity 30%.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-06-02.jpg" border="0" alt="" /></div>
<hr />
<h2><span>Step 7 </span> Navigation Buttons</h2>
<p>For the main navigation buttons we will use a rounded rectangle  shape.</p>
<p>Create a new group called ‘buttons’.</p>
<p>Create a new Rounded Rectangle Shape that’s 279×31 and offset 20 px  from the right side of the document window and vertically centred in the  navigation rectangle.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-07-01.jpg" border="0" alt="" /></div>
<p>Right click the layer in the layers palette to and select Blending  Options. Check Gradient Overlay and use the values #292c33 to #43464f.  Click OK and then check Bevel &amp; Emboss.</p>
<p>For Bevel &amp; Emboss set the size to 0px with a direction of 122  degrees. Then set the Highlight and Shadow opacity to 10% to create a  consistent, subtle lighting effect.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-07-02.jpg" border="0" alt="" /></div>
<p>Add text labels using the same font settings as were applied for the  logo type. As the button labels are contained in a smaller vertical  space we should reduce the size to 12 px and tighten the tracking to  100. Use the same colours as the logo type however apply the lighter  colour for the active page label.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-07-03.jpg" border="0" alt="" /></div>
<p>To separate the buttons while maintaining the softly lit appearance  of the navigation we should draw two lines, each 1px width. The first  should be black (#000000) and the other white (#FFFFFF). Set the opacity  for the white layer to 6% and the black layer to 12%. Duplicate these  layers by Shift-clicking each and then right clicking to selection.  Position the duplicate layers with consistent spacing inside the  navigation.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-07-04.jpg" border="0" alt="" /></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-07-06.jpg" border="0" alt="" /></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-07-07.jpg" border="0" alt="" /></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-07-08.jpg" border="0" alt="" /></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-07-09.jpg" border="0" alt="" /></div>
<hr />
<h2><span>Step 8 </span> Social Media Buttons</h2>
<p>These buttons have a different function from the rest of the nav so  we’ll apply a style that suggests this. Let’s inset these buttons to  complement the main navigation.</p>
<p>Firstly, create a new group called ‘social’ and nest this group in  the ‘navigation’ parent group.</p>
<p>Now, using the Rounded Rectangle tool with a radius of 4 px and  holding the shift key, create a square aspect shape of 25×25 px.  Vertically center this in the navigation and position the shape 22 px to  the left of the main navigation buttons.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-08-01.jpg" border="0" alt="" /></div>
<p>Right click the shape just created and select Blending Options.</p>
<p>Add a drop shadow. For this drop shadow we’ll use white (#FFFFFF) and  set the blend mode to Lighten. Set distance to 1px, spread to 0% and  size to 0px. This will create an effect of the bottom edge being lit and  hence the button being inset.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-08-02.jpg" border="0" alt="" /></div>
<p>Next, while still in the Layer Style window, check inner shadow. Use  black (#000000) with opacity at 39%, distance 1px and size 4px.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-08-03.jpg" border="0" alt="" /></div>
<p>Finally, select Color Overlay and use #353741. This will flatten the  appearance of the shape and add contrast with the background.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-08-04.jpg" border="0" alt="" /></div>
<p>For the social media icons we’ll take an existing image and trace the  edges using the pen tool to create a path (make sure Paths is select in  the tool Options menu).</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-08-05.jpg" border="0" alt="" /></div>
<p>After you’ve created a path of the icon, use the Path Selection Tool  and right-click the path you just created (make sure the path is  selected in the Paths palette). Select Define Custom Shape… Save the  Shape.</p>
<div><script type="text/javascript"></script> <script type="text/javascript"></script><ins style="display: inline-table; border: medium none; height: 250px; margin: 0pt; padding: 0pt; position: relative; visibility: visible; width: 300px;"><ins id="aswift_0_anchor" style="display: block; border: medium none; height: 250px; margin: 0pt; padding: 0pt; position: relative; visibility: visible; width: 300px;"></ins></ins></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-08-06.jpg" border="0" alt="" /></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-08-07.jpg" border="0" alt="" /></div>
<p>We can now use the icon as a scalable vector object. Using the Pen  tool, change the Options to Shape Layers (top left item on the Options  bar) and select Custom Shape Tool, then select the icon just created.  Holding the Shift key, drag the object so that it fits within the icon  tile.</p>
<p>Set the icon opacity to 20%.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-08-08.jpg" border="0" alt="" /></div>
<p>Repeat these steps for any remaining social media icons.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-08-09.jpg" border="0" alt="" /></div>
<hr />
<h2><span>Step 9 </span> More Guides</h2>
<p>In this example we’re going to be displaying folio images that are  640×480 px.</p>
<p>As we’d like to vertically center the featured image within the space  above the navigation, we need to add some more guides. Select View &gt;  New Guide and Add horizontal guides at 180px and 660px. This will  position our viewed image in the middle of the vertical space above the  navigation.</p>
<p>We’re also going to need some text at the left of the featured image  so we’ll add vertical guides at 400px and 350px to provide margin for  the text and allow space for navigation next to the image. Finally add  vertical guides at 1040px and 1070px to define the edge of the viewed  image and the margin between the adjacent image.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-10-01.jpg" border="0" alt="" /></div>
<hr />
<h2><span>Step 10 </span> Create the Image Placeholders</h2>
<p>Create a new group called ‘Projects’. Then, using the Rectangle tool,  draw a rectangle 640&#215;480px that aligns to the top left of the vertical  guide at 400px and the top to the horizontal guide at 180px. This will  serve as the placeholder for our main image.</p>
<p>Right click the layer just created and select Rasterize Layer.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-10-02.jpg" border="0" alt="" /></div>
<p>Now, holding the Alt key, click and drag the layer to create a  duplicate. Move this layer to the right of the layer with 30px margin to  align with the guide at 1070px and using the same baseline.</p>
<p>Create two more duplicates and align these to the bottom of each with  30px margin between each.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-10-03.jpg" border="0" alt="" /></div>
<p>Then, using the Paint Bucket tool, fill each of these shapes with the  color #252a3a.</p>
<hr />
<h2><span>Step 11 </span> Vignette</h2>
<p>Create a new Group called ‘Vignette’ below the ‘Navigation’ group and  above the ‘Projects’ group.</p>
<p>Create a new layer and use the Paint Bucket tool to fill the layer  using the foreground color #0f1219.</p>
<p>Using the Ellipse tool, draw an outline that intersects at the  corners of the main image guides.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-11-01.jpg" border="0" alt="" /></div>
<p>Now, to create a vignette effect, we’ll need to cut out this section  while feathering the edge of the cut. To achieve this we’ll use Select  &gt; Modify &gt; Feather. Feather the selection by 60px and then cut the  layer selection (Ctrl-x / Command-x).</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-11-03.jpg" border="0" alt="" /></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-11-04.jpg" border="0" alt="" /></div>
<hr />
<h2><span>Step 12 </span> Create Project Masks</h2>
<p>As we’re going to be showcasing work we’ll need to place some  screenshots on the placeholders. Go back the ‘Projects’ group and paste a  screenshot while the main placeholder is selected. This will insert the  layer above the placeholder. Then, right-click the layer and select  Create Clipping Mask.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-12-01.jpg" border="0" alt="" /></div>
<p>Paste three more screenshots onto the other placeholders.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-12-02.jpg" border="0" alt="" /></div>
<p>Reduce the opacity for all screenshots except for the centred  screenshot to 20%.</p>
<hr />
<h2><span>Step 13 </span> Inserting Text</h2>
<p>To annotate each project we’ll use three text layers. Create a new  group above the ‘vignette’ group to house these layers.</p>
<p>For the first, the heading, we’ll use a light font. In this example  I’ve used DIN Light however another similar typeface may also work fine.  Using the Text tool draw a text box within the guides to the left of  the main image and 40px below the top guide. Set the color to #FFFFFF,  tracking to -25 for a tighter letter spacing and use a font size of  28px.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-13-01.jpg" border="0" alt="" /></div>
<p>We’ll also add a line for the project category and date. Set the size  to 14px, tracking to 100, force caps and apply the color #338966 to  accent this line.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-13-02.jpg" border="0" alt="" /></div>
<p>Then, for the body text, we’ll use a system font such as Lucida  Grande or Lucida Sans Unicode at 12px with a color of #8C8F95 and line  height of 18px.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-13-03.jpg" border="0" alt="" /></div>
<hr />
<h2><span>Step 14 </span> Add mouse controls</h2>
<p>To navigate our folio site we’ll allow mouse or keyboard control. An  intuitive placement for navigation directional buttons is according to  their function. For example, the right arrow button will go to the right  of the main image.</p>
<p>For the buttons we’ll use translucent shapes that can shift opacity  on hover or click events. Create a new group called ‘Buttons’ that’s  above the ‘Vignette’ group.</p>
<p>Then, create a new document with the dimensions 37&#215;37px. Using the  pen tool, draw a chevron shape such as below. Repeating the process in  Step 8, using the Path Selection Tool, right click the shape and select  Define Custom Shape. Save the shape.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-14-01.jpg" border="0" alt="" /></div>
<p>Going back to our main canvas, use the Custom Shape tool to insert  the previously created shape.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-14-02.jpg" border="0" alt="" /></div>
<p>Then, select Edit &gt; Transform &gt; Flip horizontal. This will  point the arrow to the right. Clone this shape and use Edit &gt;  Transform &gt; Rotate 90 degrees Clockwise to create the downward  pointing shape.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-14-03.jpg" border="0" alt="" /></div>
<p>Position each of these shapes in the center of their respective  directional side. Allow 15px margin so the buttons can overlap the  adjacent images and reduce the opacity to 12%.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-14-04.jpg" border="0" alt="" /></div>
<hr />
<h2><span>Step 15 </span> Orientation Map</h2>
<p>To let the user know where they are in the portfolio as a whole we’ll  abstract the grid design and use lines of differing height to represent  columns of images and an indicator to establish the present viewing  position.</p>
<p>Create a new group called ‘Orientation’ and place this group above  the ‘Vignette’ group.</p>
<p>Using the Pencil tool, select Square brush set from the fly-out menu.  Then, with the color #FFFFFF and a thickness of 5px, draw a line to  align with the far left boundary guide and 60px high.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-15-01.jpg" border="0" alt="" /></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-15-02.jpg" border="0" alt="" /></div>
<p>Clone this layer and position this 2px to the right. Repeat this for  up to 12 lines.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-15-03.jpg" border="0" alt="" /></div>
<p>Set the opacity for all layers to 12%. And easy way to do this is set  the opacity for the first layer, then right click on the layer and  select Copy Layer Style. Then select all remaining layers and select  Paste Layer Style.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-15-04.jpg" border="0" alt="" /></div>
<p>Stagger these layers by using the Edit &gt; Free Transform command to  shorten / heighten each line.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-15-05.jpg" border="0" alt="" /></div>
<p>Finally, create a new layer and use the pencil again to draw a marker  on the first line. This is our position indicator.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-15-06.jpg" border="0" alt="" /></div>
<hr />
<h2><span>Step 16 </span> Keyboard controls</h2>
<p>Often keyboard control will offer an intuitive navigation experience.  However, we must allow the user to know that the keyboard may control  navigation. To accomplish this we’ll create keyboard arrow icons.</p>
<p>Create a new group called ‘Keyboard’ and place this above the  ‘Vignette’ group.</p>
<p>Using the Rectangle Shape tool, draw a square (hold Shift) 20&#215;20px  with a color #262a34. Right click the layer in the Layers palette and  select Blending Options. Check Stroke and apply a 1px stroke on the  outside with the color #32343f.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-16-01.jpg" border="0" alt="" /></div>
<p>Then, using the pen tool (ensure the style is set to Default in the  Option bar) and with color #fff draw an arrow with a slightly squared  point. Adjust as necessary with the Direct Selection tool. Set opacity  to 20%</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-16-02.jpg" border="0" alt="" /></div>
<p>In the layers palette, shift select the two layers just created.  Right click and select Duplicate layers. Then, using the Edit &gt;  Transform menu option rotate the duplicated layers to their correct  orientation. Repeat this step to create all four icons.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/115_PaulNoble/step-16-03.jpg" border="0" alt="" /></div>
<hr />
<h2>Conclusion</h2>
<p>Alright! Now we’re done with the design portion of the project… which  means all we need to do is code it using some basic HTML/CSS, <a href="http://code.google.com/p/js-hotkeys/">jQuery  Hotkeys</a>, and a few extra jQuery tricks. If anyone wants to see how  Paul coded this design, let us know in the comments so we can arrange  it!</div>
]]></content:encoded>
			<wfw:commentRss>http://www.result-search.com/m/lyman/217.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Design And Develop A Complete Website (A Tuts+ Mini Series, Pt 2)</title>
		<link>http://www.result-search.com/m/lyman/215.html</link>
		<comments>http://www.result-search.com/m/lyman/215.html#comments</comments>
		<pubDate>Wed, 13 Apr 2011 06:19:44 +0000</pubDate>
		<dc:creator>lyman</dc:creator>
				<category><![CDATA[design]]></category>

		<guid isPermaLink="false">http://www.result-search.com/m/?p=215</guid>
		<description><![CDATA[
Final Product What You&#8217;ll Be Creating



This entry is part 1 of 2 in the Design  &#38; Develop A Complete Website Session &#8211; Show All
Next »


Design And  Develop A Complete Website (A Tuts+ Mini Series, Pt 2)
Design  And Develop A Complete Website (A Tuts+ Mini Series, Pt 1) 



Today, in part 2 of [...]]]></description>
			<content:encoded><![CDATA[<div>
<h3>Final Product <span>What You&#8217;ll Be Creating</span></h3>
<div><a title="Click for Large Image" rel="external" href="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/portfolio.jpg" target="blank"><img src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/support_pages.jpg" alt="" /></a></div>
</div>
<div style="padding-top: 40px;">
<div><em>This entry is part 1 of 2 in the <strong><a href="http://webdesign.tutsplus.com/sessions/design-develop-a-complete-website/">Design  &amp; Develop A Complete Website</a></strong> Session &#8211; <a href="http://webdesign.tutsplus.com/tutorials/design-and-develop-a-complete-website-a-tuts-mini-series-pt-2/">Show All</a></em><br />
<a href="http://webdesign.tutsplus.com/tutorials/complete-websites/design-and-develop-a-complete-website-a-tuts-mini-series-pt-1/">Next »</a></div>
<div style="display: none; padding: 15px 20px 5px;">
<ul>
<li>Design And  Develop A Complete Website (A Tuts+ Mini Series, Pt 2)</li>
<li><a href="http://webdesign.tutsplus.com/tutorials/complete-websites/design-and-develop-a-complete-website-a-tuts-mini-series-pt-1/">Design  And Develop A Complete Website (A Tuts+ Mini Series, Pt 1) </a></li>
</ul>
</div>
<p><script type="text/javascript"></script><br />
Today, in part 2 of this massive tutorial, we’re continuing  this session with the second day of design. We’ve <a href="http://webdesign.tutsplus.com/tutorials/complete-websites/design-and-develop-a-complete-website-a-tuts-mini-series-pt-1/">already  designed the homepage</a> – so now we’ll be designing the four support  pages that form the rest of the complete site design (Portfolio, Blog  List, Blog Post, and the Contact Form Page). Let’s dive in shall we?</p>
<p><span id="more-2287"> </span></p>
<hr />
<h2>About the Mini Series</h2>
<p>You’ll find lots of web design and development tutorials out the net…  but very few tuts that take you from start to finish. Lots of tutorials  are only for design, and others are only for coding. Today we’re  starting a new series where we’ll design and develop a complete website  from scratch; We’ll take you from the initial wireframe to the full site  design (including 5 pages). Then we’ll be coding the design (in Nettuts  of course) and finally converting this complete XHTML theme to a  working WordPress theme!</p>
<p><a href="http://webdesign.tutsplus.com/?post_type=session&amp;p=2290">Check  out the entire process as it happens at our Session Page!</a></p>
<hr />
<h2>Project Objectives!</h2>
<p>Let’s briefly review our project objectives that we set up on <a href="http://webdesign.tutsplus.com/tutorials/complete-websites/design-and-develop-a-complete-website-a-tuts-mini-series-pt-1/">Day  One</a>:</p>
<p>Our aim is to design and develop a simple site design with a modern  layout that’s conducive to CMS systems like WordPress. We won’t be  applying any wild and crazy style effects in our design (the point here  is to keep it simple), but we are going to approach the entire process,  from start to finish, as a study in layout and a proper use of margins  and padding.</p>
<p>We’ll be using the 960 grid system from start to finish – and this  won’t be any different for our Day Two design session.</p>
<p><strong>A Brief Course Outline.</strong> We might break this up  differently once we hit the coding phase, but this should give you a  good idea of where we’re heading with this series:</p>
<ul>
<li><strong>The Design Phase</strong></li>
<li><a href="http://webdesign.tutsplus.com/tutorials/complete-websites/design-and-develop-a-complete-website-a-tuts-mini-series-pt-1/">Session  1: Laying The Groundwork and Designing the Homepage</a></li>
<li>Session 2: Designing the Support Pages (You’re reading it now!)</li>
<li><strong>The Coding Phase</strong></li>
<li>Session 3: Slicing and XTHML Coding (Available Soon)</li>
<li>Session 4: Convert To a WordPress Theme (Available Soon)</li>
</ul>
<hr />
<h2>Let’s Continue! Day Two of the Design Phase</h2>
<p>Let’s start by taking a peek at what we’ll be creating:</p>
<ul>
<li><a href="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/index.jpg" target="_blank">Homepage</a> [Done]</li>
<li><a href="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/portfolio.jpg" target="_blank">Portfolio</a> [Today]</li>
<li><a href="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/blogs.jpg" target="_blank">Blog List Page</a> [Today]</li>
<li><a href="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/blog-post.jpg" target="_blank">Blog Post Page</a> [Today]</li>
<li><a href="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/contact.jpg" target="_blank">Contact</a> [Today]</li>
</ul>
<p>Today’s design phase is also divided in four parts and we’ll design  all the other pages of Iconify in this session. As we designed the  homepage already, our primary task has been completed – so we just need  to fill in the blanks for the rest of the sitemap.</p>
<p>This is a crucial step that’s often overlooked in lots of design  projects, but designing some specifications for these support pages is  something you won’t want to skip. Remember, a website design isn’t  complete after just setting up the homepage – at the very least you’ll  need a couple extra templates designed for the additional pages that  make up a site.</p>
<p>As our layout is pretty straight forward, we’ll just be swapping out  the primary content area for each page. The universal site elements  (Header, Navigation, Footer) will all stay the same from one page to the  next. This is important to keep a consistent foundation for the site so  users always know where they’re at.</p>
<hr />
<h2><span>Part E:</span> Design the Portfolio Page</h2>
<p>The Portfolio Page is the first support page that we’ll design.  Remember that we’re using the 960 Grid System for the entire site  design, so we’ll be using the same basic layout and column structure as  we setup on the homepage design.</p>
<h3><span>Step E1:</span> Basic Setup For Portfolio Page</h3>
<p>Create a duplicate of the <strong>index.psd</strong> file and rename  it to <strong>portfolio.psd</strong>. Open it up with Photoshop. Delete  everything from within <strong>content</strong> layer group except the <strong>bg</strong> layer.</p>
<p>Now create the “breadcrumbs” and “notes” layers for the portfolio  page. For the “notes” background shape, use the same layer styles as we  did it for <strong>recent project</strong>‘s <strong>bar</strong> rectangle. Use image <strong>E – 1a</strong> as a guideline.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/e1a.jpg" alt="E - 1a" width="580" height="390" /></div>
<p>Next, we are going to use a simple technique to work in a handful of  different column variations inside this one page for our portfolio  items.</p>
<h3><span>Step E2:</span> Creating Portfolio Items</h3>
<p>Use the image creation technique from <a href="http://webdesign.tutsplus.com/tutorials/complete-websites/design-and-develop-a-complete-website-a-tuts-mini-series-pt-1/">Day  One</a> (Step C3) to create two column portfolio items as shown in  image <strong>E – 2a</strong>. If you recall, we’re simply drawing in  rectangles that fit the column guides, applying a layer style, and then  cropping in images to create a subtle border effect.</p>
<p>Now repeat this same technique for three column and four column  portfolio items. Use image <strong>E – 2b</strong> and <strong>E – 2c</strong> as a guideline. Note that we’re flipping between the different  12_column and 16_column guide layers to get this perfect. Finally,  organize your layers as shown in image <strong>E – 2d</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/e2a.jpg" alt="E - 2a" width="580" height="371" /></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/e2b.jpg" alt="E - 2b" width="580" height="434" /></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/e2c.jpg" alt="E - 2c" width="580" height="450" /></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/e2d.jpg" alt="E - 2d" width="234" height="687" /></div>
<hr />
<h2><span>Part F:</span> Design The Blog List Page</h2>
<p>The Blog List page is intended to be the location where “excerpts” of  each blog post are shown. These “excerpts” are also called “loop”  elements – and usually are comprised of a title, thumbnail image, a  short text preview and some meta information (like the date, author,  tags, etc.).</p>
<div><script type="text/javascript"></script> <script type="text/javascript"></script><script type="text/javascript"></script><script type="text/javascript"></script><script type="text/javascript"></script><script type="text/javascript"></script><ins style="display: inline-table; border: medium none; height: 250px; margin: 0pt; padding: 0pt; position: relative; visibility: visible; width: 300px;"><ins id="google_ads_frame1_anchor" style="display: block; border: medium none; height: 250px; margin: 0pt; padding: 0pt; position: relative; visibility: visible; width: 300px;"></ins></ins></div>
<h3><span> Step F1:</span> Creating the Blop “Loop” Elements</h3>
<p>Just like we did with the last page, we’ll start by creating a  duplicate of <strong>portfolio.psd</strong> page and renaming it to <strong>blogs.psd</strong>.  Inside the blogs.psd file, delete everything inside the content folder  except <strong>bg</strong>, <strong>breadcrumbs</strong>, and <strong>pages</strong> layers. Now we have a blank blogs file, we can begin to populate it  with some content.</p>
<p>For the first time we’re going to use a standard two column blog  layout – one for content and another one for the sidebar. Use image <strong>F  – 1a</strong> as guideline to design the blog and sidebar content –  notice that we’ve placed the vertical separation line between two of the  column layers so it’s perfectly spaced.</p>
<p>The actual designing here is pretty simple  so we’re not going to go  into too much detail – just follow the set rules for the type layers  (the red text on the examples), and use all of the styles that we’ve  already setup in our other pages. Take special note about the spacing  between elements (also marked in red text) as that’s going to tell you  exactly where to place everything.</p>
<p>When you’re done, organize your layers as shown in image <strong>F –  1b</strong>.</p>
<div><a title="Click to view larger size" href="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/f1a.jpg" target="_blank"><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/f1a.jpg" alt="F - 1a" /><br />
Click to view the larger size</a></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/f1b.jpg" alt="F - 1b" width="234" height="640" /></div>
<hr />
<h2><span>Part G:</span> Design the Blog Single Post Template</h2>
<p>Now that we have our Blog List page setup, we need a template for  each full blog post. This is a pretty hefty page in terms of content  because we also need to plan ahead for a commenting system and lots of  other little details. Pay special attention to the example images in  this section!</p>
<h3><span>Step G1:</span> Creating Blog Posts Page</h3>
<p>Once again, start by resaving the <strong>blogs.psd</strong> file  with a name of <strong>blog-post.psd</strong>. Inside <strong>blog-post.psd</strong>,  delete all the blog list content so we can start fresh. In the content  section, grab your text tool and start to populate with some text and  image as shown in image <strong>G – 1a</strong>.</p>
<div><a title="Click to view larger size" href="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/g1a.jpg" target="_blank"><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/g1a.jpg" alt="G - 1a" /><br />
Click to view the larger size</a></div>
<h3><span>Step G2:</span> Design The Popular Blog Post Box</h3>
<p>Draw a rectangle and apply the same layer styles of <strong>recent  project</strong>‘s <strong>bar</strong> from the index.psd file.  Populate it with content and position as shown in image <strong>G – 2a</strong>.  For the horizontal ruler styles please check image <strong>G – 2b</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/g2a.jpg" alt="G - 2a" width="580" height="307" /></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/g2b.jpg" alt="G - 2b" width="580" height="530" /></div>
<h3><span>Step G3:</span> Design The Comments Section</h3>
<p>Draw a rectangle with 630px width and any height for now. Name it <strong>bg</strong> and place it inside a layer group named <strong>comments</strong>. Copy  the layer styles from popular post box’s bg, then paste to this layer.  Use image <strong>G – 3a</strong> as a guideline.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/g3a.jpg" alt="G - 3a" width="580" height="507" /></div>
<p>For the comment boxes’ arrows, draw a triangle inside the comment box  (enable <strong>Add to shape area</strong> while drawing) measuring  10X10px rotate the arrow and position them as shown in image <strong>G –  3b</strong> and apply the layer styles as shown in image <strong>G – 3b</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/g3b.jpg" alt="G - 3b" width="580" height="900" /></div>
<p>We are leaving a 40px left margin for the second comment to indicate  that this is a reply. By using this same technique, we can go even more  deep – showing a third, fourth, or even fifth reply depth by just  indenting another 40px for each level. We’ll do the same in our XHTML  version, so remember these basic style rules.</p>
<h3><span>Step G4:</span> Design The Comment Form</h3>
<p>Draw another rectangle with same style as of <strong>comments</strong>‘s  <strong>bg</strong> layer and name this layer <strong>bg</strong>.  Place it inside a layer group named <strong>comment form</strong>. Use  image <strong>G – 4a</strong> as a guideline.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/g4a.jpg" alt="G - 4a" width="580" height="661" /></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/g4b.jpg" alt="G - 4b" width="580" height="820" /></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/g4c.jpg" alt="G - 4c" width="238" height="519" /></div>
<hr />
<h2><span>Part H:</span> Design Contact Page</h2>
<p>Once more time, copy <strong>blogs.psd</strong> and paste it with a  name of <strong>contact.psd</strong>. Open it in Photoshop. Delete  everything except breadcrumbs and sidebar from <strong>content</strong> layer group. Copy <strong>comment form</strong> and paste it as shown in  image <strong>H – 1a</strong>. Once again, type in the content as shown  in the image.</p>
<p>You’ll notice that a lot of this is repetition by now – we’re just  copy/pasting in content, fitting it to the guides that we want to use,  and using the same typography and layer styles from the previous pages.</p>
<div><a title="Click to view larger size" href="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/h1a.jpg" target="_blank"><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/h1a.jpg" alt="H - 1a" /><br />
Click to view the larger size</a></div>
<p>Things should be moving pretty quickly by the time you’ve finished  this page. You can repeat this same basic process for as many pages as  you need to mockup – just stick to the column guides and use the same  basic typographic and layer-style rules for each new design and should  be able to knock any more of these that you might need very quickly.</p>
<hr />
<h2>End of Day 2</h2>
<p>This concludes the second part of our massive tutorial! By now, we’ve  successfully designed our website. In the next session (coming soon  over at <a href="http://nettuts.com/">Nettuts</a>),  we’re going to begin the coding process, so check back here (and at <a href="http://nettuts.com/">Nettuts</a>)  as we post the new portions of this tutorial!</div>
]]></content:encoded>
			<wfw:commentRss>http://www.result-search.com/m/lyman/215.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Design And Develop A Complete Website (A Tuts+ Mini Series, Pt 1)</title>
		<link>http://www.result-search.com/m/lyman/213.html</link>
		<comments>http://www.result-search.com/m/lyman/213.html#comments</comments>
		<pubDate>Wed, 13 Apr 2011 06:19:20 +0000</pubDate>
		<dc:creator>lyman</dc:creator>
				<category><![CDATA[design]]></category>

		<guid isPermaLink="false">http://www.result-search.com/m/?p=213</guid>
		<description><![CDATA[
Final Product What You&#8217;ll Be Creating



This entry is part 2 of 2 in the Design  &#38; Develop A Complete Website Session &#8211; Show All
« Previous


Design  And Develop A Complete Website (A Tuts+ Mini Series, Pt 2) 
Design  And Develop A Complete Website (A Tuts+ Mini Series, Pt 1)



You’ll find lots of web [...]]]></description>
			<content:encoded><![CDATA[<div>
<h3>Final Product <span>What You&#8217;ll Be Creating</span></h3>
<div><a title="Click for Large Image" rel="external" href="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/final-1.jpg" target="blank"><img src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/final_600-1.jpg" alt="" /></a></div>
</div>
<div style="padding-top: 40px;">
<div><em>This entry is part 2 of 2 in the <strong><a href="http://webdesign.tutsplus.com/sessions/design-develop-a-complete-website/">Design  &amp; Develop A Complete Website</a></strong> Session &#8211; <a href="http://webdesign.tutsplus.com/tutorials/complete-websites/design-and-develop-a-complete-website-a-tuts-mini-series-pt-1/">Show All</a></em><br />
<a href="http://webdesign.tutsplus.com/tutorials/design-and-develop-a-complete-website-a-tuts-mini-series-pt-2/">« Previous</a></div>
<div style="display: none; padding: 15px 20px 5px;">
<ul>
<li><a href="http://webdesign.tutsplus.com/tutorials/design-and-develop-a-complete-website-a-tuts-mini-series-pt-2/">Design  And Develop A Complete Website (A Tuts+ Mini Series, Pt 2) </a></li>
<li>Design  And Develop A Complete Website (A Tuts+ Mini Series, Pt 1)</li>
</ul>
</div>
<p><script type="text/javascript"></script><br />
You’ll find lots of web design and development tutorials out  the net… but very few tuts that take you from start to finish. Lots of  tutorials are only for design, and others are only for coding. Today  we’re starting a new series where we’ll design and develop a complete  website from scratch; We’ll take you from the initial wireframe to the  full site design (including 5 pages). Then we’ll be coding the design  (in Nettuts of course) and finally converting this complete XHTML theme  to a working WordPress theme!</p>
<p><span id="more-2182"> </span></p>
<h2>Project Objectives!</h2>
<p>Our aim is to design and develop a simple site design with a modern  layout that’s conducive to CMS systems like WordPress. We won’t be  applying any wild and crazy style effects in our design (the point here  is to keep it simple), but we are going to approach the entire process,  from start to finish, as a study in layout and a proper use of margins  and padding.</p>
<p>We’ll be using the 960 grid system from start to finish, so if you’ve  ever wondered what it’s like to use the system, now’s a great time to  learn! We’ll be making a few deviations from the norm, but for the most  part we’ll be using 960gs in the design and coding phases.</p>
<p>Once you guys/gals are done, you’re welcome to customize the design  all you want with your own fonts, colors, styles and textures! Remember,  this is just a starting out point – you’re welcome to go as nuts as you  want when it comes to the personality of your own version of the  design.</p>
<p><strong>A Brief Course Outline.</strong> We might break this up  differently once we hit the coding phase, but this should give you a  good idea of where we’re heading with this series:</p>
<ul>
<li><strong>The Design Phase</strong></li>
<li>Session 1: Laying The Groundwork and Designing the Homepage</li>
<li>Session 2: Designing the Support Pages (Available Next Week)</li>
<li><strong>The Coding Phase</strong></li>
<li>Session 3: Slicing and XTHML Coding (Available Soon)</li>
<li>Session 4: Convert To a WordPress Theme (Available Soon)</li>
</ul>
<p><strong>Resources Used For This Project</strong></p>
<p>You can use your own resources if you’d like, but here’s the full  list of the images and icons that I’ve used in the tutorial:</p>
<ul>
<li>Images – <a href="http://www.flickr.com/photos/34540417@N07/sets/72157625208499611/">Lil  Rhody Dan</a>, Flickr</li>
<li>Merry Christmas (photo)- from <a href="http://www.flickr.com/groups/psdtuts/pool/page56/">PSDTuts  flickr group</a></li>
<li>Social Icons – <a href="http://wefunction.com/">wefunction</a></li>
<li>Twitter Bird – <a href="http://webtreats.mysitemyway.com/">webtreats</a></li>
<li>Use these values for text colors- Heading color: <strong>0f5193</strong>;  Text Color: <strong>7c7c7c</strong>; Link color: <strong>eaa000</strong></li>
</ul>
<hr />
<h2>Let’s Get Started: Day One of the Design Phase</h2>
<p>So, without further delay, let’s start on the design phase! This  design phase is divided in two parts. Today, we’ll lay out the wireframe  using the 960gs system, and we will design the homepage. In second part  (coming next week), we’ll design the other support pages.</p>
<p>The main thing you’ll want to keep track of today is how we’ll be  using two different variations of the 960gs (a 12-column layout and a  16-column layout) together in the same file. I’ll explain more about  this later, but keep track of when we use each different layout as it’ll  play a big role in the coding phase later on!</p>
<p><strong>Today’s four sub-parts are:</strong></p>
<ul>
<li><strong>Part A</strong> Laying Out the Site Wireframe</li>
<li><strong>Part B</strong> Designing the Header</li>
<li><strong>Part C</strong> Designing the Main Content Area</li>
<li><strong>Part D</strong> Designing the Footer</li>
</ul>
<hr />
<h2><span>Part A:</span> Laying Out the Site Wireframe</h2>
<h3><span>Step A1:</span> Creating A New Document Using 960gs</h3>
<p>As we are going to work with 960 grid system, go ahead and grab the  960 grid system from <a href="https://download.github.com/nathansmith-960-Grid-System-30906f2.zip">here</a> (or grab it from <a href="http://960.gs/">960.gs</a> if that link ever goes down).</p>
<p>Inside the main folder (what you have just downloaded from  http://960.gs), go to “templates-&gt;photoshop” and open  “960_grid_16_col.psd” in Photoshop. Rename this file to “index.psd” and  save it in a new folder of your choosing, as shown in image <strong>A –  1a</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/a1a.jpg" alt="A - 1a" width="580" height="640" /></div>
<p>Now that we have the 16-column file setup, we want to also import the  guide-layer from the 12-column file.</p>
<p>Open the “960_grid_<strong>12</strong>_col.psd” in Photoshop (from  the same folder you have opened the “960_grid_16_col.psd” file. Now  unlock “12 Col Grid” layer and position, then drag it to our newly  created <strong>index.psd</strong> file as shown in the image <strong>A –  1b</strong> and <strong>A – 1c</strong>. Also unlock the layer and  position of “grid_16_col”.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/a1b.jpg" alt="A - 1b" width="274" height="248" /></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/a1c.jpg" alt="A - 1c" width="580" height="450" /></div>
<p>You may be asking yourself, “<em>Why should I to use two different  grid files</em>“? As the grid_16 can’t give us three equal columns, we  need to use grid_12 as well. The 960gs system is actually built to be  used this way, so it won’t cause any conflicts down the line. We’ll also  use these two grids in the XHTML conversion phase.</p>
<p>Select the “grid_12_col” and “grid_16_col” layers, then select  “Align top edges” and “Align horizontal centers” from the options panel  as shown in image <strong>A – 1d</strong> (while selecting these  options, make sure you have also activated the <strong>Move Tool (V)</strong>).  And your final result should look like image <strong>A – 1d</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/a1d.jpg" alt="A - 1d" width="580" height="370" /></div>
<h3><span>Step A2:</span> Setting Guides, Rulers And Units</h3>
<p>It’s the time to set up our guidelines and rulers to easily position  our elements. Go to “Edit-&gt;Preferences-&gt;Units &amp; Rulers” or  press “Ctrl+K” to call the <strong>Preferences</strong> dialogue box.  Then select “Units &amp; Rulers” tab. In the “Units &amp; Rulers” pane’s  <strong>Units</strong> sub-section, set “pixels” for both “Rulers” and  “Type” options as shown in image <strong>A – 2a</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/a2a.jpg" alt="A - 2a" width="580" height="480" /></div>
<p>Now select “Guides, Grid &amp; Slices” tab and in its <strong>Grid</strong> sub-section, set value “100″ and unit to “pixels” for “Gridline every”  option. And set “10″ for “Subdivisions” field as shown in image <strong>A  – 2b</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/a2b.jpg" alt="A - 2b" width="580" height="480" /></div>
<h3><span>Step A3:</span> (Re)Sizing The Document</h3>
<p>Now press “Ctrl+Alt+C” or go to “Image-&gt;Canvas Size” to call <strong>Canvas  Size</strong> dialogue box and change settings as shown in the image <strong>A  – 3</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/a3.jpg" alt="A - 3" width="468" height="439" /></div>
<p>As we have increased our canvas height, now we have to select and  enlarge our grids according to the height of our document.</p>
<p>Select both grid layer and press “Ctrl+T” or go to “Edit-&gt;Free  Transform” then drag those grids as shown in image <strong>A – 3b</strong>.  Now lock both grid layers and hide the “grid_12_col layer” as shown in  image <strong>A – 3c</strong>.</p>
<p>By default we have positioned the <strong>guides</strong> of  grid_16_col as we are started from the <strong>grid_16_col.psd</strong> file. We don’t have guides for grid_12_col, but we really don’t need  them as we’ll only use grid_12_col in rare circumstances.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/a3b.jpg" alt="A - 3b" width="350" height="745" /></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/a3c.jpg" alt="A - 3c" width="278" height="246" /></div>
<p>You also can check your document’s grids and guides by pressing  “Ctrl+’ (View-&gt;Show-&gt;Grid)” and “Ctrl+;  (View-&gt;Show-&gt;Guides)” respectively as shown in image <strong>A –  3d</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/a3d.jpg" alt="A - 3d" width="580" height="383" /></div>
<h3><span>Step A4:</span> Creating The  Wireframe</h3>
<p>Our document width is 1020px; When using the 960 grid system, we are  supposed to use 940px for our content width. We’re going to deviate  just a bit from the 960 model by using a 20px left and right padding  (40px total) for its content column. So our total content width is going  to be 980px. Select the Background layer and press “Ctrl+Backspace” or  “Ctrl+F5″ or go to “Edit-&gt;Fill” to call <strong>Fill</strong> dialogue box, then select “Color…” option from “Use”. And set the value  to “e7e7e7″ as shown in image <strong>A – 4a</strong></p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/a4a.jpg" alt="A - 4a" width="580" height="640" /></div>
<p>If you’re having trouble doing this in older versions of Photoshop  like CS4, first “rasterize” the <strong>Background</strong> layer then  apply the background using above step.</p>
<p>Now select the “Rounded Rectangle Tool” set “Radius” to “10 px” in  the <strong>Options</strong> panel and set “Foreground” color to  “f1f1f1″. Draw a rounded rectangle in the artboard measuring size <strong>980  x 150px</strong>. Name this layer <strong>header bg</strong> and place  this layer inside a layer group and name that group <strong>Header</strong>.  And organize your layer palette as shown in image <strong>A – 4b</strong>.  And always keep grid layers above all the layers in the layer palette.</p>
<p>To create a group, simply select the layer(s) you want to set in a  group (holding down the Ctrl or Shift key) and then press “Ctrl+G” or go  to “Layer-&gt;Group Layers”. And to change a group name or layer name  simply double click on its default name then it’ll become an editable  textfield as shown in image <strong>A – 4b</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/a4b.jpg" alt="A - 4b" width="276" height="299" /></div>
<p>Select the <strong>Convert Point Tool</strong> from tool palette’s <strong>Pen  Tool</strong> group. Then “Ctrl+Click” the <strong>header bg</strong> rectangle and click on the four upper corners as shown in image <strong>A  – 4c</strong>. And delete very upper two points using <strong>Delete  Anchor Point Tool</strong> from <strong>Pen Tool</strong> group as shown  in image <strong>A – 4d</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/a4c.jpg" alt="A - 4c" width="290" height="170" /></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/a4d.jpg" alt="A - 4d" width="196" height="167" /></div>
<p>Now our <strong>header bg</strong> rectangle should have a height of  140px as we have deleted the upper two points. Select <strong>header</strong> layer group and background layer then select <strong>Align top edges</strong> and <strong>Align horizontal centers</strong> from <strong>Options</strong> palette as shown in image <strong>A – 4e</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/a4e.jpg" alt="A - 4e" width="580" height="420" /></div>
<p>Apply a layer style in the <strong>header bg</strong> layer using  settings shown in image <strong>A – 4f</strong>. Nudge this layer 1px  top to hide the top glow.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/a4f.jpg" alt="A - 4f" width="600" height="899" /></div>
<p>Now once again select the <strong>Rounded Rectangle Tool</strong> and draw content region (measuring 980 x 1400px). Name it <strong>bg</strong> and place it inside a layer group named <strong>content</strong> and  apply the same layer styles as <strong>header bg</strong>. Draw another  rectangle (measuring 980 x 570px) call it <strong>footer bg</strong> and  place it inside a layer group named <strong>footer</strong> and also  apply the same layer styles. Delete bottom two points of <strong>footer  bg</strong> rectangle using the same method of <strong>header bg</strong>.  Keep 20px distance between each section (e.g. header, content, footer).  Place everything as shown in image <strong>A – 4g</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/a4g.jpg" alt="A - 4g" width="342" height="727" /></div>
<p><strong>Wire-framing everything then adding actual content would eat  up our valuable time… So we are going to go straight to adding some  “real” content for this mockup in the next section.</strong></p>
<div><script type="text/javascript"></script> <script type="text/javascript"></script><ins style="display: inline-table; border: medium none; height: 250px; margin: 0pt; padding: 0pt; position: relative; visibility: visible; width: 300px;"><ins id="aswift_0_anchor" style="display: block; border: medium none; height: 250px; margin: 0pt; padding: 0pt; position: relative; visibility: visible; width: 300px;"></ins></ins></div>
<hr />
<h2><span>Part B:</span> Designing The Header</h2>
<h3><span>Step B1:</span> Populating The Top Portion of the Header</h3>
<p>Select the <strong>Line Tool</strong> then draw a line with 1px  weight and 940px in length (press and hold “Shift” key while drawing for  perfect line). Place it as shown in image <strong>B – 1a</strong>. Name  this layer <strong>hr</strong>, fill its background with color <strong>cdcdcd</strong> and a layer style as shown in image <strong>B – 1a</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/b1a.jpg" alt="B - 1a" width="580" height="560" /></div>
<p>Now select the <strong>Rectangle Tool</strong> and draw a 200 x 24px  rectangle, apply layer styles and place it as shown in image <strong>B –  1b</strong>. Set its background color to <strong>000000</strong> then  reduce its fill opacity to <strong>10%</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/b1b.jpg" alt="B - 1b" width="580" height="900" /></div>
<p>Type some quick link text on the left side of our <strong>search  field</strong>. Select the <strong>Text Tool</strong> from the <strong>Paragraph</strong> pane, and select <strong>Right align text</strong>. Then type some menu  names and separate them with a “|” (vertical bar). Use image <strong>B –  1c</strong> as a guideline. Set its text color to <strong>ababab</strong>.  For the <strong>search field</strong> type label <strong>Search</strong> with color <strong>ababab</strong> then select <strong>Custom Shape  Tool</strong> and from <strong>Shape</strong> menu select <strong>Search</strong> shape then draw and place the magnifier shape as shown in image <strong>B  – 1c</strong>. Set magnifier color to <strong>f1f1f1</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/b1c.jpg" alt="B - 1c" width="500" height="310" /></div>
<h3><span>Step B2:</span> Setting The Logo And Creating Navigation Menus</h3>
<p>I’m not going to guide you how to create this logo as this is not  super important that you duplicate it perfectly; I hope you’ll be able  to easily create your own logo to use. Place the existing logo (or your  own) as shown in image <strong>B – 2a</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/b2a.jpg" alt="B - 2a" width="242" height="250" /></div>
<p>Select the <strong>Text Tool</strong>, then enable the <strong>Right  align text</strong> from <strong>PARAGRAPH</strong> pane. And type some  menu names using the settings as shown in image <strong>B – 2b</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/b2b.jpg" alt="B - 2b" width="483" height="378" /></div>
<h3>span&gt;Step B3: Creating Sub-Menus</h3>
<p>Since most keyboards don’t have the “&gt;&gt;” key, first select and  copy this arrow (») then paste it in the Photoshop and name this layer <strong>arrow</strong>.  Use the same color as the menu color and set <strong>Horizontally scale</strong> to <strong>150%</strong> and select <strong>arrow</strong> layer (if  not already) press “Ctrl+T” then rotate it as shown in image <strong>B –  2c</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/b2c.jpg" alt="B - 2c" width="441" height="299" /></div>
<p>Draw a rounded rectangle with radius of 4px with any measurement.  Then set its fill color to <strong>d5d5d5</strong>, apply the shown  layer styles and type some submenu names as shown in image <strong>B –  2d</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/b2d.jpg" alt="B - 2d" width="580" height="900" /></div>
<hr />
<h2><span>Part C:</span> Designing The Main Content Section</h2>
<h3><span>Step C1:</span> Designing The Image Slider</h3>
<p>Draw a rectangle measuring 940 x 338px, then apply layer styles as  shown in image <strong>C – 1a</strong>. Name this layer <strong>slider  bdr</strong>. Place <strong>slider bdr</strong> in the <strong>content</strong> area as shown in image <strong>C – 1b</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/c1a.jpg" alt="C - 1a" width="575" height="897" /></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/c1b.jpg" alt="C - 1b" width="580" height="342" /></div>
<p>Place and select an image above the <strong>slider bdr</strong> layer then <strong>Ctrl+Click</strong> <strong>slider bdr</strong> layer  to gain slider image area (image <strong>C – 1c</strong>). Then go to  “Select-&gt;Modify-&gt;Contract” in the Contract dialogue box set 1px  and press “Enter”. Now press “Shift+Ctrl+i” or go to  “Select-&gt;Inverse” to inverse selection then hit “Delete” key from  keyboard. Now we should have a perfect image slider as in image <strong>C  – 1d</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/c1c.jpg" alt="C - 1c" width="580" height="251" /></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/c1d.jpg" alt="C - 1d" width="580" height="237" /></div>
<p>Select the <strong>Ellipse Tool</strong> and draw a circle measuring  16 x 16px. Apply a layer style as in image <strong>C – 1e</strong> and  position them as shown in image <strong>C – 1e</strong>. Group those  circles and name their layer group: radios.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/c1e.jpg" alt="C - 1e" width="580" height="750" /></div>
<h3><span>Step C2:</span> Creating the Promos &amp; Testimonial Box</h3>
<p>First, we are going to create four column promo items. To create  four columns group, enable <strong>grid_16_col</strong>. Divide those 16  columns with four and you’ll find four equal width columns. Populate  your columns with the content as shown in image <strong>C – 2a</strong>.  Next, place a line with the same settings of <strong>header</strong>‘s <strong>hr</strong> position it according to image <strong>C – 2a</strong>.</p>
<blockquote><p>When creating multiple line rules such as HRs and VRs,  it’s usually important that they have the same basic styling and color.</p></blockquote>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/c2a.jpg" alt="C - 2a" width="580" height="291" /></div>
<p>Those icons are from tutorial9. You can download them from <a href="http://www.tutorial9.net/">here</a>.</p>
<h3><span>Step C3:</span> Creating the Second Promo</h3>
<p>This is a three column promo section. For this, we’ll hide the <strong>grid_16_col</strong> and unhide <strong>grid_12_col</strong>. Use every fourth column as a  single column to place promo items. First draw a rectangle measuring 300  x 140px and place it as shown in image <strong>C – 2b</strong>. Now  place an image on top of this layer then select and crop image areas  (which are overdrawn from its lower rectangle area) as we did it for  image slider section. Now apply layer styles as shown in image <strong>C-  2b</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/c2b.jpg" alt="C - 2b" width="580" height="1200" /></div>
<p>Let’s add some text now. Select <strong>Text Tool</strong> and draw a  text block as shown in image <strong>C – 2c</strong> and type some  heading also type some short description and a link text as shown in  image <strong>C – 2c</strong>.</p>
<p>Now make a group with these layers with a name of “promo”. Then copy  and paste the “promo” group two times, and then finally group all three  “promo” groups with a name <strong>promo-col-3</strong> and position  them and your layers as shown in image <strong>C – 2d</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/c2c.jpg" alt="C - 2c" width="482" height="451" /></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/c2d.jpg" alt="C - 2d" width="580" height="379" /></div>
<h3><span>Step C4:</span> Creating The Testimonial Box</h3>
<p>Select <strong>Rectangle Tool</strong> draw a rectangle with 940px  in width and set its height according to your need. Fill this rectangle  with <strong>000000</strong> color and reduce its <strong>Fill</strong> opacity to <strong>5%</strong> and name it <strong>testi bg</strong>.</p>
<p>Now select the <strong>Custom Shape Tool</strong> from <strong>Shape</strong> menu and select the <strong>Triangle Shape</strong>. Click on the <strong>Vector  mask thumbnail</strong> of the <strong>testi bg</strong> layer. You  should have a shape selection now.</p>
<p>Enable <strong>Add to shape area (+)</strong> from the <strong>Options</strong> panel and draw a triangle inside <strong>testi bg</strong> shape. Then  with the <strong>Delete Anchor Point</strong> tool delete one side of  the triangle and place it as shown in image <strong>C – 2e</strong>.</p>
<p>Next, apply the shown layer styles, position it, and populate it with  some text as shown in image <strong>C – 2f</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/c2f.jpg" alt="C - 2f" width="580" height="800" /></div>
<h3><span>Step C5:</span> Creating Recent Project Items</h3>
<p>Select the <strong>Rectangle Tool</strong> draw a rectangle  measuring 940 x 40px and name this layer <strong>bar</strong>. Put this  rectangle inside a layer group and label this group <strong>recent  projects</strong>. Set rectangle’s fill color to <strong>FFFFFF</strong>,  and set its <strong>Fill</strong> opacity to <strong>15%</strong> then  apply layer styles to the rectangle as shown in the image <strong>C – 2g</strong> and position and place some pictures below it with the settings and  position shown as in image <strong>C – 2h</strong> and those pictures  size is 220 x 180px.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/c2g.jpg" alt="C - 2g" width="580" height="900" /></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/c2h.jpg" alt="C - 2h" width="580" height="310" /></div>
<p>For images, use the same techniques and layer styles we have used for  the <strong>promo-col-3</strong> sections. From now on, use this very  same technique and styles for designing any images for this theme in  first part and second part. Why? Because it’ll help our design have a  unified, consistent style scheme. From now on, I’ll only reference this  styles and techniques using &#8220;apply image styles&#8221; instead of repeating  all these steps.</p>
<hr />
<h2><span>Part D:</span> Designing The Footer</h2>
<h3><span>Step D1:</span> Creating the Twitter Section and Social Icons</h3>
<p>In the <strong>footer</strong> layer group create a layer group and  name it <strong>top</strong>. Inside this group place contents and  format them as shown in image <strong>D – 1a</strong>. For the vertical  ruler use the same color and layer style of horizontal ruler <strong>hr</strong>.  Finally place your layers as shown in image <strong>D – 1b</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/d1a.jpg" alt="D - 1a" width="580" height="305" /></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/d1b.jpg" alt="D - 1b" width="280" height="340" /></div>
<p>Download those social icons from <a href="http://wefunction.com/">wefunction</a> and twitter bird icon from <a href="http://webtreats.mysitemyway.com/">webtreats</a>.</p>
<p>Now create the footer’s main content.  Populate and position the  content as shown in image <strong>D – 1c</strong>. Position your layers  as shown in image <strong>D – 1d</strong>.</p>
<p><a title="Click to view larger size" href="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/d1c.jpg" target="_blank"></a></p>
<div><a title="Click to view larger size" href="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/d1c.jpg" target="_blank"><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/d1c.jpg" alt="D - 1c" width="600" /><br />
Click for the full size image</a></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/d1d.jpg" alt="D - 1d" width="235" height="392" /></div>
<p>Select the <strong>Custom Shape Tool</strong>, from <strong>Shape</strong> menu select <strong>Triangle</strong> shape and draw a triangle  measuring 10 x 10px. Fill this with color <strong>cdcdcd</strong> and  apply a stroke from layer style as shown in image <strong>D – 1e</strong>,  and name this layer <strong>top arrow</strong>. Finally add some text  and place the elements as shown in image <strong>D – 1f</strong>.</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/d1e.jpg" alt="D - 1e" width="474" height="509" /></div>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/images/d1f.jpg" alt="D - 1f" width="580" height="179" /></div>
<p>Now your design should look just about like our demo:</p>
<div><img style="display: inline;" src="http://d3pr5r64n04s3o.cloudfront.net/102_Iconify/final_600-1.jpg" alt="" /></div>
<hr />
<h2>End of Day 1</h2>
<p>This concludes the first part of our massive tutorial! By now, we’ve  successfully setup the basic framework for the site and designed our  homepage. In the next design session (coming next week), we’re going to  design the support pages. Finally, we’re going to slice the design and  get it ready for XHTML, and eventually WordPress coding!</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.result-search.com/m/lyman/213.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Design a Sleek, Dark Mobile App Website (Updated!)</title>
		<link>http://www.result-search.com/m/lyman/210.html</link>
		<comments>http://www.result-search.com/m/lyman/210.html#comments</comments>
		<pubDate>Wed, 13 Apr 2011 06:17:18 +0000</pubDate>
		<dc:creator>lyman</dc:creator>
				<category><![CDATA[design]]></category>

		<guid isPermaLink="false">http://www.result-search.com/m/?p=210</guid>
		<description><![CDATA[
Final Product What You&#8217;ll Be Creating




Download Source Files
Demo View It Online


Now Updated with a Coding Tutorial and the free PSD! In this tutorial we’ll be using Adobe Photoshop to design a sleek web  interface that can be used for any mobile app website. We’ll be covering  an array of techniques including shapes, textures, [...]]]></description>
			<content:encoded><![CDATA[<div>
<h3>Final Product <span>What You&#8217;ll Be Creating</span></h3>
<div><a title="Click for Large Image" rel="external" href="http://leafletapp.com/" target="blank"><img src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/final.jpg" alt="" /></a></div>
</div>
<div style="padding-top: 40px;">
<div>
<div><a rel="external" href="http://webdesigntutsplus.s3.amazonaws.com/051_Leaflet_Tutorial/Leaflet_PSD.zip" target="blank"><span>Download</span> <small>Source Files</small></a></div>
<div><a rel="external" href="http://nettuts.s3.amazonaws.com/899_leaflet/Source/index.html" target="blank"><span>Demo</span> <small>View It Online</small></a></div>
</div>
<p><script type="text/javascript"></script><br />
<strong>Now Updated with a Coding Tutorial and the free PSD!</strong> In this tutorial we’ll be using Adobe Photoshop to design a sleek web  interface that can be used for any mobile app website. We’ll be covering  an array of techniques including shapes, textures, masks, custom icons,  typography and much more that can be easily adapted and applied to your  own web designs.</p>
<p><span id="more-1506"> </span></p>
<hr />
<h2>The Coding Portion of the Tutorial</h2>
<p>Eric has offered the PSD for Leaflet for free to all of our readers  here. If you’re a premium Tut+ member, hop over to our sister site, <a href="http://net.tutsplus.com/tutorials/site-builds/build-a-sleek-dark-mobile-app-website-new-premium-tutorial/">Nettuts</a>,  for the <a href="http://net.tutsplus.com/tutorials/site-builds/build-a-sleek-dark-mobile-app-website-new-premium-tutorial/">full  coding portion of the tutorial</a> as well. Eric will walk you through  how to take this design into a full coded HTML/CSS template!</p>
<p>For those unfamiliar, the family of <a href="http://tutsplus.com/">Tuts+</a> sites runs a premium membership service. For $9 per month, you gain  access to exclusive premium tutorials, screencasts, and freebies from <a href="http://net.tutsplus.com/">Nettuts+</a>, <a href="http://psd.tutsplus.com/">Psdtuts+</a>, <a href="http://photo.tutsplus.com/">Phototuts+</a>, <a href="http://ae.tutsplus.com/">Aetuts+</a>, <a href="http://audio.tutsplus.com/">Audiotuts+</a>, <a href="http://vector.tutsplus.com/">Vectortuts+</a>, and <a href="http://cg.tutsplus.com/">CgTuts+</a> For the price of a pizza,  you’ll learn from some of the best minds in the business. <a href="http://net.tutsplus.com/about/join-plus/">Become a Premium member</a> to read this tutorial, as well as hundreds of other advanced tutorials  and screencasts.</p>
<p>Alright, on to the free design portion of the tut!</p>
<hr />
<h2>About This Design</h2>
<p>This tutorial is based on the dark, clean website design for <a href="http://leafletapp.com/">Leaflet</a>,  an iPhone app designed for Envato marketplace publishers. Eric Alli of <a href="http://trilabmedia.com/">Trilab  Media</a> helped design and code the site, so he’ll be walking us  through the step by step tutorial. Whether you’re looking to use a  similar design for your own projects or just want to see how it was  made, there are plenty of excellent tricks and techniques in this  tutorial that you’ll be able to pick up on. Enjoy!</p>
<hr />
<h2><span>Step 1</span></h2>
<p>Let’s begin by creating a new Photoshop document by selecting File  &gt; New.</p>
<p>Set both the canvas Width and Height to 1100px, Resolution to 72, and  the Background Contents to White.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/1a.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Next, we need to create two guides that will act as the container for  our page.</p>
<p>Select View &gt; New Guide…</p>
<p>For the first guide, set the Orientation to Vertical and the Position  to 70 px.</p>
<p>For the second guide, select View &gt; New Guide… again and create  another Vertical guide with the Position set to 1030 px.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/1b.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>We should now have an outlined space that is 960px in width for our  page.</p>
<hr />
<h2><span>Step 2</span></h2>
<p>Next step is the background. Select the Paint Bucket Tool (G) and set  your Foreground Color Swatch to “1e1e1e”. Then, click anywhere on the  canvas to apply the color to our Background layer.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/2a.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Let’s also add a bit of texture to our background by selecting Filter  &gt; Noise &gt; Add Noise…</p>
<p>Set the Amount to 2.5 and click OK.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/2b.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<hr />
<h2><span>Step 3</span></h2>
<p>Next we’re going to create a spotlight that will help add focus to  the top area of our page.</p>
<p>Select the Brush Tool (B) and change the Master Diameter to 400px and  set the Hardness to 0%.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/3a.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Create a new layer by selecting Layer &gt; New &gt; Layer… and give  it the name of “Spotlight”.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/3b.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Change your Foreground Color Swatch to “FFFFFF” (white) and create a  circle near the top of the canvas using the Brush tool.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/3c.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>To help blend the spotlight into the background, lets add some noise  to the spotlight layer by selecting Filter &gt; Add Noise…</p>
<p>Set the Amount to 20, check Monochromatic and click OK.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/3d.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>To smooth out our spotlight, select Filter &gt; Blur &gt; Gaussian  Blur…</p>
<p>Set the Radius to 50.0 and click OK.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/3e.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Finally set the Opacity on the Spotlight layer to around 25%.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/3d.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<hr />
<h2><span>Step 4</span></h2>
<p>Next we’re going to be adding our phone graphics. For this tutorial I  will be using the iPhone graphic from the superb <a href="http://psd.tutsplus.com/freebies/psd/freebie-vector-iphone-4-psd-file/">Vector  iPhone 4 PSD</a> from Psdtuts+ which can be downloaded for free <a href="http://psdtuts.s3.amazonaws.com/Freebie_0008_iPhone/Freebie_0008_iPhone.zip">here</a>.  Also keep in mind, you may use any phone graphic that suits your  particular needs (Android, Blackberry, etc…).</p>
<p>Once downloaded, open the PSD in Photoshop. Expand the “Phones”  folder in the Layers panel, right click the “FRONT” folder and select  Duplicate Group… Here, give the group a recognizable name (I used  “iPhone”), set the destination to “Leaflet” (or whatever it is you named  your PSD for this tutorial), and click OK. Once you’re finished, close  this PSD.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/4a.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Position our first iPhone touching the left guide and around 100px  from the top of the canvas.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/4b.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>This is also a good time to customize the screenshot within the  iPhone.</p>
<p>An easy way to do this is to expand the “iPhone” folder in our layers  panel then click on the “SCREEN CONTENTS” folder. Now select File &gt;  Place, choose your screenshot from the browser, then click Place.</p>
<p>Drag your placed layer over the iPhone and resize to fit into the  screen. Once finish, click Enter to save the changes.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/4c.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Duplicate the “iPhone” group by selecting Layer &gt; Duplicate Group…  name it “iPhone 2″ and click OK on the dialog.</p>
<p>Select Edit &gt; Transform &gt; Scale and expand the duplicated  iPhone to 107.0% width and height. Position this iPhone around 50px from  the top and 200px from the left guide.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/4d.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Repeat the step mentioned above to replace the screenshot within the  “iPhone 2″ folder.</p>
<hr />
<h2><span>Step 5</span></h2>
<p>The final touch for our iPhones is to create a reflection of them.  Lets start by selecting both iPhone groups (“iPhone” and “iPhone 2″)  then select Layer &gt; Duplicate Layers… and click OK. Then select Layer  &gt; Merge Layers.</p>
<p>Next we need to flip our iPhones upside down. Select Edit &gt;  Transform &gt; Flip Vertical, then position the flipped layer directly  under the original iPhones.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/5a.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Add a Layer Mask by clicking the Layer Mask icon in the Layers Panel.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/5b.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Select the Gradient Tool (G) and choose a black to white swatch. Draw  a line from top to bottom on the flipped iPhones that is around 50px in  height.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/5c.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Finally, lower the opacity on the layer to 30%.</p>
<hr />
<h2><span>Step 6</span></h2>
<p>Next is to add our app’s main details to the right of our phones.  Before we start, lets add another guide to keep things aligned. Select  View &gt; New Guide… select “Vertical” for orientation and 550 px for  position.</p>
<p>At around 100px from the top of our canvas, we’re going to add in our  logo. I’m using a logo I’ve previously made, you can simply use text or  insert your own logo here.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/6a.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Below the logo, we’re going to add a paragraph of text for our app’s  description. Select the Horizontal Type Tool (T) and draw a rectangle  between the center guide and the right guide. Set the character settings  as follows:</p>
<ul>
<li><strong>Font Family</strong>: Helvetica Neue</li>
<li><strong>Size</strong>: 16 px</li>
<li><strong>Style</strong>: Regular</li>
<li><strong>Leading</strong>: 26 px</li>
<li><strong>Tracking</strong>: -25</li>
<li><strong>Anti-aliasing</strong>: Crisp</li>
<li><strong>Color</strong>: #FFFFFF</li>
</ul>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/6b.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<hr />
<h2><span>Step 7</span></h2>
<p>Next we’ll create a button for visitors to purchase our app. Using  the Rounded Rectangle Tool (U), draw a 240&#215;75px rectangle with a 4px  radius. Align it so the left side of the button touches the center guide  and it’s 45px below the text.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/7a.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Now we’ll apply some layer styles. Double-click the right side of the  layer in the Layers Panel and use the below image for reference.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/7b.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>To add the Apple icon, draw a small text box inside the button using  the Horizontal Type Tool (T), then copy and paste this symbol:  into  the text box and set the character settings as follows:</p>
<ul>
<li><strong>Font Family</strong>: Helvetica Neue</li>
<li><strong>Size</strong>: 50 px</li>
<li><strong>Style</strong>: Regular</li>
<li><strong>Anti-aliasing</strong>: Crisp</li>
<li><strong>Color</strong>: #000000</li>
</ul>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/7c.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Finally, change the opacity on this layer to 30%.</p>
<p>Create another text box to the right and add 2 lines of text (ex:  “Download now on the App Store”). Apply the following character  settings:</p>
<ul>
<li><strong>Font Family</strong>: Helvetica Neue</li>
<li><strong>Size</strong>: 11 px (first line) 24 px (second line)</li>
<li><strong>Style</strong>: Bold</li>
<li><strong>Leading</strong>: 26 px</li>
<li><strong>Tracking</strong>: -25</li>
<li><strong>Anti-aliasing</strong>: Crisp</li>
<li><strong>Color</strong>: #FFFFFF</li>
</ul>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/7d.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Add a Layer style to this text using the following image for  reference:</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/7e.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Next, we’re going to add a separator to the right of the text we’ve  just added. Select the Line Tool (U) and while holding the SHIFT key,  draw a 1px line from the top of the button to the bottom, then change  the line’s color to “FFFFFF” (white).</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/7f.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Change the opacity of this line to 15% and duplicate it by selecting  Layer &gt; Duplicate Layer… and click OK. Change the color of this  duplicated line to #000000 (black) and change it’s opacity to 10%. Then,  move the duplicated line 1px to the left.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/7g.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>The last element to add to this button is an icon that indicates  download. Begin by selecting the Ellipse Tool (U) and creating a circle  that is 25px in diameter.</p>
<div><script type="text/javascript"></script> <script type="text/javascript"></script><ins style="display: inline-table; border: medium none; height: 250px; margin: 0pt; padding: 0pt; position: relative; visibility: visible; width: 300px;"><ins id="aswift_0_anchor" style="display: block; border: medium none; height: 250px; margin: 0pt; padding: 0pt; position: relative; visibility: visible; width: 300px;"></ins></ins></div>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/7h.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Then, add the following Layer Styles:</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/7i.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Finally, grab the Custom Shape Tool (U) and choose an arrow shape  (I’m using a default shape called “Arrow 9″). Create a small arrow 10px  in width inside the circle and change the color to “FFFFFF” (white).</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/7j.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<hr />
<h2><span>Step 8</span></h2>
<p>Now to create a small box to display our app’s price. Select the  Rounded Rectangle Tool (U), set the Radius to 4px and create a rectangle  that overlaps our download button and is 52px in height and any width  greater then 100px.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/8a.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Change the color of this box to “2B2B2B” and move it below the  download button in the Layers Panel.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/8b.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Next, add a Stroke Layer Style to this box with the following  settings:</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/8c.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Now we can add the actual price information. For this we’re going to  create two separate text boxes since the content within requires  different styling.</p>
<p>For the first text box, add some text (I used “ONLY”) and apply the  following character settings:</p>
<ul>
<li><strong>Font Family</strong>: Helvetica Neue</li>
<li><strong>Size</strong>: 19 px</li>
<li><strong>Style</strong>: Bold</li>
<li><strong>Anti-aliasing</strong>: Crisp</li>
<li><strong>Color</strong>: #FFFFFF</li>
</ul>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/8d.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>For the second text box, add your price (I used “$1.99″) and apply  the following character settings:</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/8e.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<hr />
<h2><span>Step 9</span></h2>
<p>Moving on to the bottom portion of our page, we need to create some  separation. For this, we’ll use the two-line technique we applied  earlier on the download button to give the separator an “inset” look.</p>
<p>Select the Line Tool (U) and while holding the SHIFT key, draw a 1px  line from the left guide to the right guide, then change the line’s  color to “000000″ (black).</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/9a.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Change the opacity of this line to 80% and duplicate it by selecting  Layer &gt; Duplicate Layer… and click OK. Change the color of this  duplicated line to “FFFFFF” (white) and change it’s opacity to 10%.  Then, move the duplicated line 1px down so it’s under the black line.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/9b.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<hr />
<h2><span>Step 10</span></h2>
<p>In the section below the line separator we’ve just created, we’re  going to be adding two columns, for screenshots and a list of features.</p>
<p>Starting with screenshots, begin by importing your first screenshot  by selecting File &gt; Place. Choose our screenshot from the file  browser and click Place. Resize the screenshot to 80% width and height,  then move the screenshot near the left guide and click Enter.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/10a.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Select the layer in the Layers Panel and click the “Add Mask” button  twice to add a Vector Mask.</p>
<p>Now select the Rounded Rectangle Tool (U) and change the radius to  6px and create a rectangle over the screenshot with the size of  175&#215;120px.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/10b.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Lastly, we’re going to add a Stroke Layer Style with the following  settings:</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/10c.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Repeat the above steps for all of your screenshots and give them 35px  of space between each other.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/10d.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<hr />
<h2><span>Step 11</span></h2>
<p>To separate our screenshots from the features, draw a 1px line from  the top of the first screenshot to the bottom of the last screenshot  that is around 55px from the screenshots.</p>
<p>Change the line’s color to “FFFFFF” (white) and set it’s opacity to  5%.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/11a.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<hr />
<h2><span>Step 12</span></h2>
<p>Let’s add a title that will describe our features (I used “Leaflet  Features”). Position the text 55px from the left separator line and use  the following character settings:</p>
<ul>
<li><strong>Font Family</strong>: Helvetica Neue</li>
<li><strong>Size</strong>: 24 px</li>
<li><strong>Style</strong>: Regular</li>
<li><strong>Tracking</strong>: -10</li>
<li><strong>Anti-aliasing</strong>: Crisp</li>
<li><strong>Color</strong>: #FFFFFF</li>
</ul>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/12a.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Now let’s create our list of features and position it below the  title. Create a text box and add five or six lines of features and give  them the following character settings:</p>
<ul>
<li><strong>Font Family</strong>: Helvetica Neue</li>
<li><strong>Size</strong>: 15 px</li>
<li><strong>Style</strong>: Regular</li>
<li><strong>Leading</strong>: 28 px</li>
<li><strong>Tracking</strong>: -10</li>
<li><strong>Anti-aliasing</strong>: Sharp</li>
<li><strong>Color</strong>: #8d8c90</li>
</ul>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/12b.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Repeat the above steps to add the app’s requirements.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/12c.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<hr />
<h2><span>Step 13</span></h2>
<p>To make our list of features stand out, let’s create some simple,  custom bullets.</p>
<p>Start by shifting the list of features text box 25px to the right.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/13a.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Now select the Ellipse Tool (U) and create a circle that is 9px in  diameter to the left of the first feature. Change the circle’s color to  “bce086″.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/13b.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Add the following Layer Style to the circle:</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/13c.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<hr />
<h2><span>Step 14</span></h2>
<p>Now we need to duplicate our bullets and align them to each feature.  Start by duplicating the circle layer by selecting the layer then  clicking Layer &gt; Duplicate Layer…</p>
<p>Next, move the duplicated layer down 28px (the amount of Leading we  applied to the feature list). Repeat the above steps three times.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/14a.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<hr />
<h2><span>Step 15</span></h2>
<p>Moving on to the footer portion of our page, we’ll once again apply  the two-line technique we applied earlier in <strong>Step 9</strong> to  add some separation.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/15a.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<hr />
<h2><span>Step 16</span></h2>
<p>Now we can add some useful links to our footer area. First we need to  create four text boxes, side-by-side, that will hold our links.</p>
<p>Start by creating a text box that is around 160&#215;40px. Add some text  to it and repeat 3 times. Here is some sample text you can use:</p>
<ul>
<li><strong>Box 1</strong>: Follow @mycompany on Twitter for news and  updates.</li>
<li><strong>Box 2</strong>: For help &amp; support head to our Support  area.</li>
<li><strong>Box 3</strong>: Download our press and media kit.</li>
<li><strong>Box 4</strong>: Copyright 2010 My Company, LLC.</li>
</ul>
<p>Use the following for the character settings:</p>
<ul>
<li><strong>Font Family</strong>: Helvetica Neue</li>
<li><strong>Size</strong>: 12 px</li>
<li><strong>Style</strong>: Regular</li>
<li><strong>Leading</strong>: 20 px</li>
<li><strong>Anti-aliasing</strong>: Sharp</li>
<li><strong>Color</strong>: #5555552</li>
</ul>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/16a.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>As you may notice our boxes are uneven and not aligned properly,  don’t worry, we’ll be fixing this in the next step.</p>
<hr />
<h2><span>Step 17</span></h2>
<p>To fix our alignment issues, begin by placing the four text boxes  we’ve created above into a folder and name it “Footer”.</p>
<p>First, position the first text box 55px from the left guide and the  last text box touch the right guide.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/17a.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Now select the four text layers in the Footer folder and grab the  Move Tool (V). Click on the Align vertical centers button, then click  Distribute horizontal centers button from the Move toolbar.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/17b.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<hr />
<h2><span>Step 18</span></h2>
<p>Now we can add some custom icons to accentuate our links.</p>
<p>Select the Ellipse Tool (U) and create a circle that is 36px in  diameter next to our first text box. Change the color of this circle to  “FFFFFF” (white).</p>
<p>Now select Layer &gt; Rasterize &gt; Layer.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/18a.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Next up is to add our icon to this circle. For the first icon, I’m  using the Twitter “t” that i’ve downloaded for free <a href="http://www.iconfinder.com/icondetails/56005/128/099376_twitter_icon">here</a>.</p>
<p>Once downloaded, select File &gt; Place in photoshop to import the  icon into our document. Once imported, resize the icon to 28% width and  height, position it over our circle, then click enter.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/18b.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>Next, right-click on the thumbnail of the Twitter icon in the Layers  Panel and click Select Pixels.</p>
<p>Now select the circle layer in the Layers Panel then select Edit &gt;  Clear.</p>
<p>Delete the imported Twitter Icon by selecting it in the Layers panel  and click or drag it to the Trash icon.</p>
<p>Finally, lower the opacity on the circle layer to 15%.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/18c.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<hr />
<h2><span>Step 19</span></h2>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/19a.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<p>For the rest of the icons shown above, repeat the steps in <strong>Step  18</strong> by using other icons or with custom shapes in photoshop.</p>
<hr />
<h2><span>Step 20</span></h2>
<p>To add a finishing touch to our footer links, lets give them a hit of  color to help them stand out.</p>
<p>Using the Horizontal Text Tool (T) highlight a part of the text in  each text box and change it’s color to “83b546″.</p>
<div><img style="display: inline;" title="Sleek Mobile App Website  Tutorial" src="http://d3pr5r64n04s3o.cloudfront.net/051_Leaflet_Tutorial/20a.jpg" border="0" alt="Sleek Mobile App Website Tutorial" /></div>
<h2>Conclusion</h2>
<p>That’s all! I hope you’ve enjoyed this tutorial and have found some  useful techniques that you can adapt / apply to your next design.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.result-search.com/m/lyman/210.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

