<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2spanishfull.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>emenia.es</title>
	
	<link>http://www.emenia.es</link>
	<description>Creación y diseño web</description>
	<lastBuildDate>Mon, 31 May 2010 14:34:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Emeniaes" /><feedburner:info uri="emeniaes" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:feedFlare href="http://add.my.yahoo.com/content?lg=es&amp;url=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://eur.i1.yimg.com/eur.yimg.com/i/es/my/addto1.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.feedness.com/alta/http://feeds.feedburner.com/Emeniaes" src="http://www.feedness.com/ayuda/wp-content/square_b_sh_feed.gif">Subscribe with Feedness</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/Emeniaes" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare href="http://www.plusmo.com/add?url=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://plusmo.com/res/graphics/fbplusmo.gif">Subscribe with Plusmo</feedburner:feedFlare><feedburner:feedFlare href="http://www.thefreedictionary.com/_/hp/AddRSS.aspx?http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://img.tfd.com/hp/addToTheFreeDictionary.gif">Subscribe with The Free Dictionary</feedburner:feedFlare><feedburner:feedFlare href="http://www.bitty.com/manual/?contenttype=rssfeed&amp;contentvalue=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://www.bitty.com/img/bittychicklet_91x17.gif">Subscribe with Bitty Browser</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsalloy.com/?rss=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://www.newsalloy.com/subrss3.gif">Subscribe with NewsAlloy</feedburner:feedFlare><feedburner:feedFlare href="http://www.live.com/?add=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><feedburner:feedFlare href="http://mix.excite.eu/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://image.excite.co.uk/mix/addtomix.gif">Subscribe with Excite MIX</feedburner:feedFlare><feedburner:feedFlare href="http://download.attensa.com/app/get_attensa.html?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://www.attensa.com/blogs/attensa/WindowsLiveWriter/BadgeredintoBadges_10C02/attensa_feed_button5.gif">Subscribe with Attensa for Outlook</feedburner:feedFlare><feedburner:feedFlare href="http://www.webwag.com/wwgthis.php?url=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://www.webwag.com/images/wwgthis.gif">Subscribe with Webwag</feedburner:feedFlare><feedburner:feedFlare href="http://www.podcastready.com/oneclick_bookmark.php?url=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://www.podcastready.com/images/podcastready_button.gif">Subscribe with Podcast Ready</feedburner:feedFlare><feedburner:feedFlare href="http://www.flurry.com/pushRssFeed.do?r=fb&amp;url=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://www.flurry.com/images/flurry_rss_logo2.gif">Subscribe with Flurry</feedburner:feedFlare><feedburner:feedFlare href="http://www.wikio.com/subscribe?url=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://www.wikio.com/shared/img/add2wikio.gif">Subscribe with Wikio</feedburner:feedFlare><feedburner:feedFlare href="http://www.dailyrotation.com/index.php?feed=http%3A%2F%2Ffeeds.feedburner.com%2FEmeniaes" src="http://www.dailyrotation.com/rss-dr2.gif">Subscribe with Daily Rotation</feedburner:feedFlare><item>
		<title>Crear una lista de productos con Wordpress 3.0 usando Entradas personalizadas, campos personalizados y taxonomías</title>
		<link>http://feedproxy.google.com/~r/Emeniaes/~3/UP349wJaIj8/</link>
		<comments>http://www.emenia.es/lista-productos-wordpress-3/#comments</comments>
		<pubDate>Sun, 30 May 2010 16:34:01 +0000</pubDate>
		<dc:creator>Juan Diaz-Bustamante</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.emenia.es/?p=875</guid>
		<description><![CDATA[Una de las grandes novedades que incorpora Wordpress 3.0 es la posibilidad de crear <strong>Entradas Personalizadas (Custom Post Types)</strong>, es decir un nuevo tipo de entradas parecidas a las Entradas normales y a las Páginas, y que <strong>aparecerán también de manera separada en el menú de la izquierda del administrador de Wordpress</strong>. ¿Qué ventajas nos ofrecen las Entradas Personalizadas? Una mayor facilidad de uso de nuestro tema, estructurando mejor los distintos tipos de entradas.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.emenia.es%2Flista-productos-wordpress-3%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.emenia.es%2Flista-productos-wordpress-3%2F&amp;source=JuanDBB_Emenia&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Una de las grandes novedades que incorpora Wordpress 3.0 es la posibilidad de crear <strong>Entradas Personalizadas (Custom Post Types)</strong>, es decir un nuevo tipo de entradas parecidas a las Entradas normales y a las Páginas, y que <strong>aparecerán también de manera separada en el menú de la izquierda del administrador de Wordpress</strong>. ¿Qué ventajas nos ofrecen las Entradas Personalizadas? Una mayor facilidad de uso de nuestro tema, estructurando mejor los distintos tipos de entradas. Por ejemplo, si queremos insertar una lista de productos con una serie de características comunes, podemos crear una estradas personalizadas que se llamen <strong>Producto</strong> y que estén configuradas de manera específica para insertar dichos productos. En vez de decirle a nuestro cliente que cree una entrada normal y que rellene toda una serie de campos personalizados sólo utilizables para insertar un producto pero no para cualquier otra entrada, que no se equivoque con las categorías que son sólo para productos y no para el resto de entradas, etc.. ahora símplemente tendrá que hacer click en &#8220;Productos&#8221; y rellenar cada campo específico para ese tipo de entrada.</p>
<p><a href="http://www.emenia.es/wp-content/uploads/2010/05/menu_admin.png"><img src="http://www.emenia.es/wp-content/uploads/2010/05/menu_admin.png" alt="" title="menu_admin" width="500" height="293" class="aligncenter size-full wp-image-880" /></a></p>
<p>Pero como siempre, esto se verá mejor con un ejemplo. Vamos a crear una entrada personalizada que se llame &#8220;Productos&#8221;. Con el permiso de <a href="http://www.friendware.es" title="Ir a Friendware">Friendware</a> (su web la hice yo hace un par de años) vamos a usar algunos de sus juegos para PC. Cada producto va a tener un título, una descripción, un precio, un fabricante, una plataforma y una imagen.</p>
<p>Vamos a usar campos personalizados para el precio y el fabricante y taxonomías personalizadas para la Plataforma (en realidad Fabricante debería ser una taxonomía, pero lo pongo como campo personalizado para ver mejor cómo se crean varios).</p>
<p><strong>En el administrador vamos a tener en el menú de la izquierda:</strong></p>
<p><a href="http://www.emenia.es/wp-content/uploads/2010/05/menu_admin2.png"><img src="http://www.emenia.es/wp-content/uploads/2010/05/menu_admin2.png" alt="" title="menu_admin2" width="500" height="302" class="aligncenter size-full wp-image-887" /></a></p>
<p><strong>Si hacemos click sobre Añadir tendremos:</strong></p>
<p><a href="http://www.emenia.es/wp-content/uploads/2010/05/anadir_producto.png"><img src="http://www.emenia.es/wp-content/uploads/2010/05/anadir_producto.png" alt="" title="anadir_producto" width="500" height="418" class="aligncenter size-full wp-image-890" /></a></p>
<p><strong>Y al hacer click sobre Editar tendremos una tabla con todos los productos:</strong></p>
<p><a href="http://www.emenia.es/wp-content/uploads/2010/05/editar_producto.png"><img src="http://www.emenia.es/wp-content/uploads/2010/05/editar_producto.png" alt="" title="editar_producto" width="550" height="361" class="aligncenter size-full wp-image-893" /></a><br />
<strong><br />
Pero ahora viene lo mejor.</strong> Si tenemos activados los enlaces permanentes podemos ir a una url que sea por ejemplo www.miweb.es/Productos/ donde se vean todos los productos introducidos con los estilos que hayamos definido:</p>
<p><a href="http://www.emenia.es/wp-content/uploads/2010/05/productos1.jpg"><img src="http://www.emenia.es/wp-content/uploads/2010/05/productos1.jpg" alt="" title="productos" width="500" height="570" class="aligncenter size-full wp-image-926" /></a><br />
<strong><br />
Bien, ya sabemos lo que vamos a crear. Ahora vamos a ver paso a paso cómo crearlo.</strong> No he visto ningún artículo completo que indique todos lo pasos de manera completa. Por ello me he basado en diferentes artículos y webs. Sus enlaces están al final del artículo.</p>
<h3>Paso 1: Crear una Entrada Personalizada</h3>
<p>La mejor manera que he encontrado para crear una Entrada Personalizada es utilizando la <a href="http://somadesign.ca/projects/smarter-custom-post-types/" title="Ir al blog de Matt Wiebe">clase creada por Matt Wiebe</a>. La razón es que además de crear una función que nos permite crear Entradas Personalizadas con gran facilidad, añade a la función que habitualmente crea entradas personalizadas (<a href="http://codex.wordpress.org/Function_Reference/register_post_type">register_post_type</a>) una serie de funcionalidades extra:</p>
<p>   1. URLs personalizadas para cada Entrada Personalizada. (ejemplos http://miweb.com/productos/, http://miweb.com/productos/page/2/, http://miweb.com/productos/feed/ )<br />
   2. Archivos personalizados para cada Entrada Personalizada, por ejemplo producto/index.php o producto.php en el directorio de nuestro tema.<br />
   3. Páginas individuales personalizadas: WP busca el fichero single-producto.php (en su defecto por single.php). Con esta función podemos usar producto/single.php para una mejor organización..<br />
   4. Añade clases a body_class() y a post_class().<br />
   5. Auto genera las etiquetas apropiadas para el Administrador si no suministras una.</p>
<p>El punto 1 me parece muy importante, ya que Wordpress 3.0, al menos en la beta 2, no crea por defecto una url donde podamos ver todas las entradas de una misma entrada personalizada (por ejemplo, todos los productos).</p>
<p>El código, que habría que llevar al archivo functions.php, lo podemos descargar <a href="http://somadesign.ca/projects/smarter-custom-post-types/">desde la web de Matt Wiebe</a>. Una vez tengamos ese código pegado en el archivo functions.php de nuestro tema, escribiremos a continuación para crear la Entrada Personalizada &#8220;Producto&#8221;:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">sd_register_post_type<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Producto'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Aquí está el código completo. Hay que tener en cuenta que Matt Wiebe está continuamente mejorando esta función añadiendo nuevas características, por lo que estad pendientes de sus actualizaciones.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
 * Copyright 2010 Matt Wiebe.
 *
 * This code is licensed under the GPL v2.0
 * http://www.opensource.org/licenses/gpl-2.0.php
 *
 * If you do something cool with it, let me know! http://somadesign.ca/contact/
 *
 * Version 1.3
 *
 * === Changelog ===
 *
 * 1.0
 *  - Initial release
 * 1.1
 *  - Added feed support in URL rewrites
 * 1.2
 *  - Removed redundant post_class code.
 *  - Removed redundant single post_type template code
 *  - Introduced directory support for template files
 * 1.3
 *  - Use the newer, more robust labels array to set defaults
 *  - Add possible support for adding post_type to nav_menus. Commented out by default since the 'show_in_nav_menus' $arg should provide for that, although it doesn't seem to work right now.
 *
 */</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * SD_Register_Post_Type class
 *
 * @author Matt Wiebe
 * @link http://somadesign.ca
 *
 * @param string $post_type The post type to register
 * @param array $args The arguments to pass into @link register_post_type(). Some defaults provided to ensure the UI is available.
 * @param string $custom_plural The plural name to be used in rewriting (http://yourdomain.com/custom_plural/ ). If left off, an &quot;s&quot; will be appended to your post type, which will break some words. (person, box, ox. Oh, English.)
 **/</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #990000;">class_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'SD_Register_Post_Type'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">class</span> SD_Register_Post_Type <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$post_type</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$post_slug</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$args</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$post_type_object</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$defaults</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'show_ui'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'public'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'supports'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'editor'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'thumbnail'</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> set_defaults<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$plural</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ucwords</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_slug</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$post_type</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ucwords</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_type</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">defaults</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'labels'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
				<span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$plural</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'singular_name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$post_type</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'add_new_item'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Add New '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$post_type</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'edit_item'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Edit '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$post_type</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'new_item'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'New '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$post_type</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'view_item'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'View '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$post_type</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'search_items'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Search '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$plural</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'not_found'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'No '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$plural</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' found'</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'not_found_in_trash'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'No '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$plural</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' found in Trash'</span>
			<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post_type</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$custom_plural</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #000088;">$post_type</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">// meat n potatoes</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_type</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$post_type</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_slug</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$custom_plural</span> <span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$custom_plural</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$post_type</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'s'</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">// a few extra defaults. Mostly for labels. Overridden if proper $args present.</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_defaults</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">// sort out those $args</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">args</span> <span style="color: #339933;">=</span> wp_parse_args<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">defaults</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">// magic man</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add_actions</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add_filters</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> add_actions<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'register_post_type'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'template_redirect'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'context_fixer'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> add_filters<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'generate_rewrite_rules'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'add_rewrite_rules'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'template_include'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'template_include'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			add_filter<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'body_class'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'body_classes'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> context_fixer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> get_query_var<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'post_type'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_type</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">is_home</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> add_rewrite_rules<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$wp_rewrite</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$new_rules</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$new_rules</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_slug</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/page/?([0-9]{1,})/?$'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'index.php?post_type='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_type</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;paged='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">preg_index</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$new_rules</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_slug</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/(feed|rdf|rss|rss2|atom)/?$'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'index.php?post_type='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_type</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;feed='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">preg_index</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$new_rules</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_slug</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/?$'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'index.php?post_type='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_type</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rules</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_merge</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_rules</span><span style="color: #339933;">,</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rules</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$wp_rewrite</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> register_post_type<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			register_post_type<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_type</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">args</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> template_include<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$template</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> get_query_var<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post_type'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_type</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> is_single<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$single</span> <span style="color: #339933;">=</span> locate_template<span style="color: #009900;">&#40;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_type</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/single.php'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
						<span style="color: #b1b100;">return</span> <span style="color: #000088;">$single</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// loop</span>
					<span style="color: #b1b100;">return</span> locate_template<span style="color: #009900;">&#40;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
						<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_type</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/index.php'</span><span style="color: #339933;">,</span>
						<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_type</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.php'</span><span style="color: #339933;">,</span>
						<span style="color: #0000ff;">'index.php'</span>
					<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$template</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> body_classes<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$c</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> get_query_var<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post_type'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_type</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_type</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$c</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'type-'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_type</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$c</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// end SD_Register_Post_Type class</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * A helper function for the SD_Register_Post_Type class. Because typing &quot;new&quot; is hard.
	 *
	 * @author Matt Wiebe
	 * @link http://somadesign.ca
	 *
	 * @uses SD_Register_Post_Type class
	 * @param string $post_type The post type to register
	 * @param array $args The arguments to pass into @link register_post_type(). Some defaults provided to ensure the UI is available.
	 * @param string $custom_plural The plural name to be used in rewriting (http://yourdomain.com/custom_plural/ ). If left off, an &quot;s&quot; will be appended to your post type, which will break some words. (person, box, ox. Oh, English.)
	 **/</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'sd_register_post_type'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">class_exists</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'SD_Register_Post_Type'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">function</span> sd_register_post_type<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post_type</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$args</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$custom_plural</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$custom_post</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SD_Register_Post_Type<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post_type</span><span style="color: #339933;">,</span> <span style="color: #000088;">$args</span><span style="color: #339933;">,</span> <span style="color: #000088;">$custom_plural</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
sd_register_post_type<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Producto'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Del código de Matt Wiebe hay que destacar esta parte:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$defaults</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">'show_ui'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'public'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'supports'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'editor'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'thumbnail'</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>La línea que pone &#8217;supports&#8217; crea una cadena con los campos que soporta la Entrada Personalizada, en este caso el Título (title), el Contenido (editor) y la Imagen Destacada (thumbnail). Podemos ver todos los componentes posibles y más información sobre register_post_type en <a href="http://codex.wordpress.org/Function_Reference/register_post_type">la web de wordpress</a>. Como vemos, podríamos haber añadido  &#8216;author&#8217;, &#8216;excerpt&#8217; o  &#8216;custom-fields&#8217; por ejemplo.</p>
<p>Ahora podemos crear en el directorio de nuestro tema un archivo <strong>producto.php</strong> que recoja todos los productos introducidos y un archivo <strong>single-producto.php</strong> que muestre cada producto individual.  </p>
<p><strong>Archivo producto.php:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> get_header<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
  &lt;div id=&quot;container&quot;&gt;
    &lt;div id=&quot;content&quot;&gt;
      <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
          <span style="color: #000000; font-weight: bold;">&lt;?php</span>
             <span style="color: #000088;">$custom</span> <span style="color: #339933;">=</span> get_post_custom<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
             <span style="color: #000088;">$precio</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$custom</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;precio&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
             <span style="color: #000088;">$fabricante</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$custom</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;fabricante&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
           <span style="color: #000000; font-weight: bold;">?&gt;</span>
           &lt;div id=&quot;post-<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_ID<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; <span style="color: #000000; font-weight: bold;">&lt;?php</span> post_class<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&gt;
            &lt;h2 class=&quot;entry-title&quot;&gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; title=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;&lt;/h2&gt;
             &lt;div class=&quot;entry-meta&quot;&gt;
                   &lt;div class=&quot;entry-content&quot;&gt;
                    <span style="color: #000000; font-weight: bold;">&lt;?php</span> the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
                    <span style="color: #000000; font-weight: bold;">&lt;?php</span> the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
                     &lt;p class=&quot;caracteristicas&quot;&gt;Precio: <span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$precio</span><span style="color: #000000; font-weight: bold;">?&gt;</span> - Fabricante: <span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$fabricante</span><span style="color: #000000; font-weight: bold;">?&gt;</span> - <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> get_the_term_list<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'plataforma'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Plataforma: '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">', '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/p&gt;
                   &lt;/div&gt;
             &lt;/div&gt;
         &lt;/div&gt;
      <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
  &lt;div&gt;&lt;!-- #content --&gt;
&lt;/div&gt;&lt;!-- #container --&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_sidebar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_footer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong>Ojo: </strong>En la línea p class=&#8221;caracteristicas&#8221; hemos incluido la taxonomía &#8220;Plataforma&#8221; que aún no hemos creado (la creamos más abajo).</p>
<p>Archivo single-producto.php:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> get_header<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
   &lt;div id=&quot;container&quot;&gt;
     &lt;div id=&quot;content&quot;&gt;
       <span style="color: #000000; font-weight: bold;">&lt;?php</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
       <span style="color: #000000; font-weight: bold;">&lt;?php</span>
         <span style="color: #000088;">$custom</span> <span style="color: #339933;">=</span> get_post_custom<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         <span style="color: #000088;">$precio</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$custom</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;precio&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
         <span style="color: #000088;">$fabricante</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$custom</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;fabricante&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">?&gt;</span>
        &lt;div id=&quot;post-<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_ID<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; <span style="color: #000000; font-weight: bold;">&lt;?php</span> post_class<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&gt;
         &lt;h1 class=&quot;entry-title&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> - <span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$precio</span><span style="color: #000000; font-weight: bold;">?&gt;</span> - <span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$fabricante</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/h1&gt;
          &lt;div class=&quot;entry-meta&quot;&gt;
    	   &lt;div class=&quot;entry-content&quot;&gt;
	     <span style="color: #000000; font-weight: bold;">&lt;?php</span> the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	   &lt;/div&gt;
         &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;&lt;!-- #content --&gt;
&lt;/div&gt;&lt;!-- #container --&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_sidebar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_footer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Una vez tengamos todo este código listo podremos introducir nuestros Productos y podremos verlos todos en la url www.nuestraweb.com/Productos gracias a producto.php y podremos ver cada producto en concreto en la url www.nuestraweb.com/Productos/nombre-del-producto gracias a single-producto.php (hay que tener activados los enlaces permanentes. Si sale &#8220;página no encontrada&#8221; volved a grabar los enlaces permanentes ya que a veces necesitan actualizarse).</p>
<h3>Paso 2- Crear los Campos Personalizados</h3>
<p>A continuación vamos a crear los Campos Personalizados Precio y Fabricante para nuestras Entradas Personalizadas. Lo haremos siguiendo <a href="http://net.tutsplus.com/tutorials/wordpress/rock-solid-wordpress-3-0-themes-using-custom-post-types/">este artículo de Nettuts+</a>. Ahora podremos darle a nuestros campos personalizados nombre propios claros para saber lo que es cada uno (en este caso Precio y Fabricante). Para ello añadimos a functions.php este código:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">add_action(&quot;admin_init&quot;, &quot;admin_init&quot;);
add_action('save_post', 'guardar_precio');
add_action('save_post', 'guardar_fabricante');
&nbsp;
function admin_init(){
  add_meta_box(&quot;prodInfo-meta&quot;, &quot;Opciones Producto&quot;, &quot;meta_options&quot;, &quot;Producto&quot;, &quot;normal&quot;, &quot;low&quot;);
}
function meta_options(){
  global $post;
  $custom = get_post_custom($post-&gt;ID);
  $precio = $custom[&quot;precio&quot;][0];
  $fabricante = $custom[&quot;fabricante&quot;][0];
?&gt;
  &lt;label&gt;Precio:&lt;/label&gt;&lt;input name=&quot;precio&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$precio</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;&lt;br /&gt;&lt;br /&gt;
  &lt;label&gt;Fabricante:&lt;/label&gt;&lt;input name=&quot;fabricante&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$fabricante</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> guardar_precio<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
  update_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;precio&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;precio&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> guardar_fabricante<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
  update_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;fabricante&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;fabricante&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>La primera linea indica que cuando se inicialice el panel de administración se llame a la función admin_init(). Esta función dice a WordPress que añada un área llamada &#8220;Opciones Producto&#8221; para cualquier Entrada Personalizada llamada Producto y que use la función meta_options() para mostrar los campos del formulario. Puedes <a href="http://codex.wordpress.org/Function_Reference/add_meta_box">leer más sobre add_meta_box aquí</a>. meta_options() obtendrá entonces cualquier valor preexistente y lo mostrará en el formulario. Las dos lineas de acción que siguen a la primera línea hacen que cuando se grabe una entrada se llame a las funciones guardar_precio() y guardar_fabricante() que utilizan update_post_meta() para añadir o actualizar los campos personalizados &#8220;Precio&#8221; y &#8220;Fabricante&#8221;.</p>
<h3>Paso 3 &#8211; Crear Taxonomías personalizadas asociadas</h3>
<p>Una vez tengamos nuestras Entradas Personalizadas es posible que queramos tener una serie de Taxonomías que nos ayuden a clasificar los distintos productos según determinadas categorías. Podemos ver más información sobre las taxonomías en el artículo <a href="http://www.emenia.es/taxonomias-en-wordpress/">Taxonomías en Wordpress</a>.</p>
<p>Vamos a crear, como dijimos, una Taxonomía personalizada llamada &#8220;Plataforma&#8221;, donde podremos poner si el juego es para PC CD-ROM, Playstation 3, etc&#8230; Para ello escribimos en functions.php:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">register_taxonomy<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;plataforma&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Producto&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;hierarchical&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;label&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Plataforma&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;singular_label&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Plataforma&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;rewrite&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Puedes encontrar más información sobre la función register_taxonomy() <a href="http://codex.wordpress.org/Function_Reference/register_taxonomy">en la web de Wordpress</a>. Aquí creamos una nueva Taxonomía llamada &#8220;Plataforma&#8221; y la asociamos a la entrada personalizada &#8220;Producto&#8221;. Para poder ver luego la taxonomía escribiríamos (como hemos visto más arriba en producto.php):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> get_the_term_list<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'plataforma'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Plataforma: '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">', '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Paso 4 &#8211; Crear la tabla de productos en el panel de administración</h3>
<p>Vimos al principio de este artículo que al hacer click sobre Editar en Producto salía una tabla con el nombre de cada producto, su descripción, precio, fabricante y plataforma. Esto no se crea por defecto. Para conseguirlo, <a href="http://net.tutsplus.com/tutorials/wordpress/rock-solid-wordpress-3-0-themes-using-custom-post-types/">tal y como vemos en el mismo artículo de nettuts+</a>, hay que añadir en functions.php:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;manage_edit-Producto_columns&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;prod_edit_columns&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;manage_posts_custom_column&quot;</span><span style="color: #339933;">,</span>  <span style="color: #0000ff;">&quot;prod_custom_columns&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> prod_edit_columns<span style="color: #009900;">&#40;</span><span style="color: #000088;">$columns</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$columns</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
      <span style="color: #0000ff;">&quot;cb&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;&lt;input type=<span style="color: #000099; font-weight: bold;">\&quot;</span>checkbox<span style="color: #000099; font-weight: bold;">\&quot;</span> /&gt;&quot;</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">&quot;title&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Nombre del Producto&quot;</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">&quot;descripcion&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Descripción&quot;</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">&quot;precio&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Precio&quot;</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">&quot;plataforma&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Plataforma&quot;</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">&quot;fabricante&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Fabricante&quot;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$columns</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> prod_custom_columns<span style="color: #009900;">&#40;</span><span style="color: #000088;">$column</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$column</span><span style="color: #009900;">&#41;</span>
       <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;descripcion&quot;</span><span style="color: #339933;">:</span>
	   the_excerpt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	   <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;precio&quot;</span><span style="color: #339933;">:</span>
	   <span style="color: #000088;">$custom</span> <span style="color: #339933;">=</span> get_post_custom<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	   <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$custom</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;precio&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	   <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;fabricante&quot;</span><span style="color: #339933;">:</span>
	   <span style="color: #000088;">$custom</span> <span style="color: #339933;">=</span> get_post_custom<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	   <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$custom</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;fabricante&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	   <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;plataforma&quot;</span><span style="color: #339933;">:</span>
	   <span style="color: #b1b100;">echo</span> get_the_term_list<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'plataforma'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">', '</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	   <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>En prod_edit_columns() tenemos un array donde los índices (keys) de cada variable se usan para referenciar cierta información de las entradas que definimos en la segunda función, prod_custom_columns() y donde los valores son las cabeceras de las columnas. En prod_edit_columns() hay 6 columnas pero sólo mostramos 4 en prod_custom_columns() ya que ‘cb’ y ‘title’ son parte de los índices por defecto de Wordpress para los que ya tiene asociaciones creadas.</p>
<p>Bueno, ¡y eso sería todo! Con este código adecuadamente incluído podemos tener las pantallas que veíamos al principio del artículo. Pero como véis hay mucho campo para ampliar las posibilidades que se nos ofrecen con las Entradas Personalizadas. Aquí hemos hecho una lista de Productos, pero podría haber sido las habitaciones de un hotel, una lista de canciones de distintos autores, una lista de libros o cualquier cosa que se nos ocurra.</p>
<h3>Otras lecturas recomendadas</h3>
<p><a href="http://somadesign.ca/projects/smarter-custom-post-types/">Smarter Custom Post Types</a><br />
<a href="http://net.tutsplus.com/tutorials/wordpress/rock-solid-wordpress-3-0-themes-using-custom-post-types/">Rock-Solid WordPress 3.0 Themes using Custom Post Types </a><br />
<a href="http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress">Custom post types in WordPress</a><br />
<a href="http://justintadlock.com/archives/2010/02/02/showing-custom-post-types-on-your-home-blog-page">Showing custom post types on your home/blog page</a><br />
<a href="http://kovshenin.com/archives/custom-post-types-in-wordpress-3-0/">Custom Post Types in WordPress 3.0</a><br />
<a href="http://kovshenin.com/archives/extending-custom-post-types-in-wordpress-3-0/">Extending Custom Post Types in WordPress 3.0</a><br />
<a href="http://net.tutsplus.com/tutorials/wordpress/introducing-wordpress-3-custom-taxonomies/">Introducing WordPress 3 Custom Taxonomies</a></p>
<div id="crp_related"><h3>Artículos relacionados:</h3><ul><li><a href="http://www.emenia.es/taxonomias-en-wordpress/" rel="bookmark" class="crp_title">Taxonomías en Wordpress</a></li><li><a href="http://www.emenia.es/nuevo-en-wordpress-2-9-miniaturas-de-entrada-post-thumbnails/" rel="bookmark" class="crp_title">Nuevo en Wordpress 2.9: Miniaturas de Entrada (Post Thumbnails)</a></li><li><a href="http://www.emenia.es/recopilacion-de-45-trucos-para-wordpress/" rel="bookmark" class="crp_title">Recopilación de 45 trucos para Wordpress</a></li><li><a href="http://www.emenia.es/barra-lateral-diferente-para-cada-pagina-en-wordpress/" rel="bookmark" class="crp_title">Barra Lateral diferente para cada página en Wordpress</a></li><li><a href="http://www.emenia.es/como-separar-los-articulos-por-categorias-en-wordpress/" rel="bookmark" class="crp_title">Cómo separar los artículos por categorías en Wordpress</a></li></ul></div><img src="http://feeds.feedburner.com/~r/Emeniaes/~4/UP349wJaIj8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.emenia.es/lista-productos-wordpress-3/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.emenia.es/lista-productos-wordpress-3/</feedburner:origLink></item>
		<item>
		<title>Nuevas fuentes a través de Google para tu web</title>
		<link>http://feedproxy.google.com/~r/Emeniaes/~3/fHydvg9Zo6w/</link>
		<comments>http://www.emenia.es/nuevas-fuentes-google-para-tu-web/#comments</comments>
		<pubDate>Thu, 20 May 2010 16:34:05 +0000</pubDate>
		<dc:creator>Juan Diaz-Bustamante</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.emenia.es/?p=867</guid>
		<description><![CDATA[<a href="http://googlecode.blogspot.com/2010/05/introducing-google-font-api-google-font.html">Google ha anunciado</a> su nuevo API para fuentes, incluyendo un <a href="http://code.google.com/webfonts">directorio de fuentes</a> y una herramienta para visualizarlas. Esto nos permitirá incluir en nuestra web fuentes diferentes de las tradicionales (las que están incluídas en el directorio de fuentes de Google). La gran ventaja es <a href="http://code.google.com/apis/webfonts/docs/getting_started.html#Quick_Start">su facilidad de uso</a>. Símplemente hay que incluir un enlace al CSS de la fuente en Google y luego asignar la fuente al elemento que deseemos desde nuestra hoja de estilos.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.emenia.es%2Fnuevas-fuentes-google-para-tu-web%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.emenia.es%2Fnuevas-fuentes-google-para-tu-web%2F&amp;source=JuanDBB_Emenia&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://googlecode.blogspot.com/2010/05/introducing-google-font-api-google-font.html">Google ha anunciado</a> su nuevo API para fuentes, incluyendo un <a href="http://code.google.com/webfonts">directorio de fuentes</a> y una herramienta para visualizarlas. Esto nos permitirá incluir en nuestra web fuentes diferentes de las tradicionales (las que están incluídas en el directorio de fuentes de Google). La gran ventaja es <a href="http://code.google.com/apis/webfonts/docs/getting_started.html#Quick_Start">su facilidad de uso</a>. Símplemente hay que incluir un enlace al CSS de la fuente en Google y luego asignar la fuente al elemento que deseemos desde nuestra hoja de estilos.</p>
<p>Como vemos se trata símplemente de aplicar <strong>@font-face</strong>, pero con la ventaja de cargar la fuente desde Google, lo cual permite mejorar la velocidad de carga y reducir el consumo de ancho de banda (es como cargar jQuery desde Google).</p>
<p>Vamos con un ejemplo. Elejimos una fuente desde el <a href="http://code.google.com/webfonts">directorio de fuentes de Google</a>, por ejemplo <strong>Josefin Sans Std Light</strong>. Vemos que al poner el ratón sobre la misma aparece un botón que dice <em>Click to embed Josefin Sans Std Light</em>. Al hacer click iremos a una página que nos muestra los distintos tamaños y estilos disponibles para la fuente, una descripción y el set de caracteres. Además hay una pestaña que dice <strong>Get the Code</strong>. Si hacemos click sobre la misma vemos que nos dice que tenemos que pegar dentro del head de nuestra página:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;link href='http://fonts.googleapis.com/css?family=Josefin+Sans+Std+Light' rel='stylesheet' type='text/css' /&gt;</pre></td></tr></table></div>

<p>Ojo que la etiqueta en Google viene sin cerrar. Arriba yo la he cerrado para que valide bien la página.</p>
<p>Luego, en nuestra hoja de estilos, si queremos asignar esta fuente a los elementos h1 haríamos:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">h1 <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">'Josefin Sans Std Light'</span><span style="color: #00AA00;">,</span> arial<span style="color: #00AA00;">,</span> <span style="color: #993333;">serif</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Y eso es todo!  Según nos dicen en Google este sistema es compatible con Google Chrome: versión 4.249.4+,  Mozilla Firefox: versión: 3.5+, Apple Safari: versión 3.1+ y Microsoft Internet Explorer: versión 6+.<br />
No soportado por iPhone, iPad, iPod, o Android.</p>
<p><a href="http://www.emenia.es/demos-blog/google-fonts/index.html">Aquí podéis ver la demo</a>. Esperemos que el número de fuentes se vaya incrementando.</p>
<h3>Otras lecturas de interés</h3>
<p><a href="http://googlecode.blogspot.com/2010/05/introducing-google-font-api-google-font.html">Anuncio de Google sobre el API de fuentes (en Inglés)</a><br />
<a href="http://code.google.com/webfonts">Directorio de fuentes de Google</a></p>
<div id="crp_related"><h3>Artículos relacionados:</h3><ul><li><a href="http://www.emenia.es/utilizando-css3-hoy-5-font-face/" rel="bookmark" class="crp_title">Utilizando CSS3 hoy (5): @font-face</a></li><li><a href="http://www.emenia.es/taxonomias-en-wordpress/" rel="bookmark" class="crp_title">Taxonomías en Wordpress</a></li><li><a href="http://www.emenia.es/primeros-pasos-tras-una-nueva-instalacion-de-wordpress/" rel="bookmark" class="crp_title">Primeros pasos tras una nueva instalación de Wordpress</a></li><li><a href="http://www.emenia.es/curso-de-jquery-3-selectores-segunda-parte/" rel="bookmark" class="crp_title">Curso de jQuery (3): Selectores, Segunda Parte</a></li><li><a href="http://www.emenia.es/recopilacion-de-45-trucos-para-wordpress/" rel="bookmark" class="crp_title">Recopilación de 45 trucos para Wordpress</a></li></ul></div><img src="http://feeds.feedburner.com/~r/Emeniaes/~4/fHydvg9Zo6w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.emenia.es/nuevas-fuentes-google-para-tu-web/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.emenia.es/nuevas-fuentes-google-para-tu-web/</feedburner:origLink></item>
		<item>
		<title>Creando un menú vertical desplegable con jQuery (2)</title>
		<link>http://feedproxy.google.com/~r/Emeniaes/~3/sLGMZDkRbs0/</link>
		<comments>http://www.emenia.es/creando-un-menu-vertical-desplegable-con-jquery-2/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 06:10:07 +0000</pubDate>
		<dc:creator>Juan Diaz-Bustamante</dc:creator>
				<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://www.emenia.es/?p=853</guid>
		<description><![CDATA[Tras una pregunta de Saúl sobre el artículo <a href="http://www.emenia.es/creando-un-menu-vertical-desplegable-con-jquery/">Creando un menú vertical desplegable con jQuery</a> en la que me preguntaba cómo lograr que al abrir una opción del menú se cerrara cualquier otra que estuviera abierta (podéis ver la pregunta en la zona de comentarios del artículo anterior) he actualizado (bueno, básicamente cambiado) el código para que pueda hacerse lo que pide Saúl. Aunque lo he puesto en los comentarios respondiéndole me he animado a crear una nueva entrada por si a alguien le fuera de interés.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.emenia.es%2Fcreando-un-menu-vertical-desplegable-con-jquery-2%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.emenia.es%2Fcreando-un-menu-vertical-desplegable-con-jquery-2%2F&amp;source=JuanDBB_Emenia&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Tras una pregunta de Saúl sobre el artículo <a href="http://www.emenia.es/creando-un-menu-vertical-desplegable-con-jquery/">Creando un menú vertical desplegable con jQuery</a> en la que me preguntaba cómo lograr que al abrir una opción del menú se cerrara cualquier otra que estuviera abierta (podéis ver la pregunta en la zona de comentarios del artículo anterior) he actualizado (bueno, básicamente cambiado) el código para que pueda hacerse lo que pide Saúl. Aunque lo he puesto en los comentarios respondiéndole me he animado a crear una nueva entrada por si a alguien le fuera de interés.</p>
<p>Lo que queremos conseguir es esto: <a href="http://www.emenia.es/demos-blog/menu-desplegable2/" rel="nofollow">Ejemplo de menú vertical desplegable con jQuery con efecto acordeón</a></p>
<p>Como veréis en el ejemplo, el código HTML completo del navegador es:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;ul class=&quot;navegador&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#&quot; class=&quot;desplegable&quot; title=&quot;Venta&quot;&gt;Venta&lt;/a&gt;
    &lt;ul class=&quot;subnavegador&quot;&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;Viviendas&quot;&gt;Viviendas&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;Aparcamientos&quot;&gt;Aparcamientos&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a class=&quot;desplegable&quot; href=&quot;#&quot; title=&quot;Alquiler&quot;&gt;Alquiler&lt;/a&gt;
    &lt;ul class=&quot;subnavegador&quot;&gt;
       &lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;Viviendas&quot;&gt;Viviendas&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;Oficinas&quot;&gt;Oficinas&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;Ofertas&quot;&gt;Ofertas&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;Oficina de Ventas&quot;&gt;Oficina de Ventas&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre></td></tr></table></div>

<p>Y el código jQuery que lo hace posible:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
  $<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// Script del Navegador</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul.subnavegador&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">not</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.selected'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a.desplegable&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> desplegable <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul.subnavegador&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.desplegable'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul.subnavegador&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">not</span><span style="color: #009900;">&#40;</span>desplegable<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      desplegable.<span style="color: #660066;">slideToggle</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      e.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Si tenéis alguna pregunta no dudéis en preguntar.</p>
<div id="crp_related"><h3>Artículos relacionados:</h3><ul><li><a href="http://www.emenia.es/creando-un-menu-vertical-desplegable-con-jquery/" rel="bookmark" class="crp_title">Creando un menú vertical desplegable con jQuery</a></li><li><a href="http://www.emenia.es/lista-desplegable-y-plegable-con-jquery/" rel="bookmark" class="crp_title">Lista desplegable y plegable con jQuery</a></li><li><a href="http://www.emenia.es/como-pre-cargar-imagenes-con-jquery/" rel="bookmark" class="crp_title">Cómo pre-cargar imágenes con jQuery</a></li><li><a href="http://www.emenia.es/como-separar-los-articulos-por-categorias-en-wordpress/" rel="bookmark" class="crp_title">Cómo separar los artículos por categorías en Wordpress</a></li><li><a href="http://www.emenia.es/recopilacion-de-45-trucos-para-wordpress/" rel="bookmark" class="crp_title">Recopilación de 45 trucos para Wordpress</a></li></ul></div><img src="http://feeds.feedburner.com/~r/Emeniaes/~4/sLGMZDkRbs0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.emenia.es/creando-un-menu-vertical-desplegable-con-jquery-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.emenia.es/creando-un-menu-vertical-desplegable-con-jquery-2/</feedburner:origLink></item>
		<item>
		<title>Filtrar el spam de un formulario con Akismet</title>
		<link>http://feedproxy.google.com/~r/Emeniaes/~3/fDcNlvZ_skE/</link>
		<comments>http://www.emenia.es/formulario-filtrar-spam-akismet/#comments</comments>
		<pubDate>Sun, 11 Apr 2010 10:40:18 +0000</pubDate>
		<dc:creator>Juan Diaz-Bustamante</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.emenia.es/?p=842</guid>
		<description><![CDATA[Wordpress incorpora un servicio para filtrar el Spam de los comentarios llamado Akismet. Podemos utilizar también Akismet fuera de Wordpress ya que está disponible para gran cantidad de CMS, lenguajes y frameworks. Vamos a ver su uso para PHP 5.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.emenia.es%2Fformulario-filtrar-spam-akismet%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.emenia.es%2Fformulario-filtrar-spam-akismet%2F&amp;source=JuanDBB_Emenia&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Los que hayáis creado webs o blogs con Wordpress sabéis ya que incorpora un potente servicio  llamado <a href="http://akismet.com/" title="Ir a la web de Akismet">Akismet</a> para verificar, filtrar y reportar si un mensaje es considerado Spam. Aunque sus comienzos proceden de Wordpress existen ya <a href="http://akismet.com/development/" title="ver plugins">gran cantidad de plugins</a> para otros CMS (Drupal, Joomla, Expression Engine&#8230;), lenguajes y frameworks (PHP, Ruby, Phyton, Java, Ruby on Rails, Coldfusion, Codeigniter&#8230;.). </p>
<p>Vamos a centrarnos en el <a href="http://www.achingbrain.net/stuff/php/akismet" title="Web oficical del plugin de Akismet para PHP5">plugin para PHP 5</a>.</p>
<p>Lo primero que tenemos que hacer es descargarnos Akismet:<br />
<a href="http://www.achingbrain.net/files/PHP5Akismet/PHP5Akismet.0.4.zip"  title="Descargar Akismet para PHP5">PHP5Akismet.0.4.zip</a> 24K</p>
<p>A continuación descomprimimos el archivo <em>Akismet.class.php</em> y lo archivamos en una carpeta de nuestro proyecto (a efectos de este ejemplo suponemos que lo guardamos en la carpeta <em>&#8220;includes&#8221;</em>)</p>
<p>Ahora ya estamos listos para usarlo. Hay que tener en cuenta que en nuestro formulario deberíamos tener además un sistema de validación (tanto en Javascript como en PHP) adicionales. Una vez que el formulario enviado pase dichos filtros estaríamos en condiciones de establecer un filtro más, el de Akismet:</p>
<h3>Primer paso: obtener la clave (API key)</h3>
<p>Para usar Akismet necesitamos antes de nada obtener una clave (API key) para activar y usar Akismet. Esta clave es gratuita y la podemos obtener <a href="http://akismet.com/personal/" title="Obtener clave Akismet">desde la misma página de Akismet</a>. Debéis tener en cuenta que hay ciertas condiciones de uso para las cuales necesitaríais obtener una clave comercial.</p>
<p>En el formulario se nos pide una dirección de correo electrónico, la enviamos y recibiremos la clave.</p>
<h3>Segundo paso: Incluir Akismet en nuestro código</h3>
<p>Una vez tengamos la clave ya podemos incluir Akismet. Como vimos más arriban tenemos el archivo <em>Akismet.class.php</em> dentro de la carpeta <em>&#8220;includes&#8221;</em>. Para incluirlo hacemos símplemente:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Incluimos la clase Akismet</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'includes/Akismet.class.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>Incluir la clave (API key)</h3>
<p>El siguiente paso es incluir la clave que nos ha proporcionado Akismet así como la URL de nuestra web</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//Introducirmos la API key para nuestra web</span>
<span style="color: #000088;">$api_key</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'aqui va la clave'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$blog_url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://www.miweb.com&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>Creamos el objeto Akismet</h3>
<p>A continuación creamos el objeto Akismet:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Creamos el objeto Akismet</span>
<span style="color: #000088;">$akismet</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Akismet<span style="color: #009900;">&#40;</span><span style="color: #000088;">$blog_url</span> <span style="color: #339933;">,</span><span style="color: #000088;">$api_key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>Probamos si la clave (API key) es válida</h3>
<p>Estas líneas sólo nos serviran para comprobar si la clave que tenemos es válida. Una vez veamos que todo va bien las podemos eliminar. O también podemos incluir todo el código que crearemos a continuación dentro del condicional, para que sólo se ejecute si la clave es válida.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$akismet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isKeyValid</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p&gt;La clave es buena&lt;/p&gt;'</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// api key es buena</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> 
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p&gt;La clave no vale&lt;/p&gt;'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// api key no es buena</span>
 <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h3>Definir los campos a filtrar</h3>
<p>A continuación establecemos qué campos de nuestro formulario son los que vamos a filtrar contra Spam. En este caso suponemos el nombre, e-mail, el comentario y una url. Las variables proceden del código que deberíamos haber creado previamente para obtener los valores de $_POST enviados por el formulario que una vez validados se asignan a cada variable.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$akismet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setCommentAuthor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$nombre</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #000088;">$akismet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setCommentAuthorEmail</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$email</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$akismet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setCommentContent</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$comentarios</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$akismet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setCommentAuthorURL</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>Establecer el enlace permanente donde el formulario es enviado</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Enlace permanente donde el formulario es enviado</span>
<span style="color: #000088;">$akismet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setPermalink</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://www.ejemplo.com/una-url/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>Condicional si se considera spam</h3>
<p>Para saber si Akismet considera que es Spam podemos hacer:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$akismet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isCommentSpam</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
 <span style="color: #666666; font-style: italic;">// Aquí va el código, mensaje de error o lo que queramos, o incluso archivarlos en algún sitio para comprobarlos más adelante</span>
 <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">// Aquí va el código en el caso de que NO sea Spam</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Y eso es todo, como véis es muy sencillo de usar. Todo el código junto:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Incluimos la clase Akismet</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'includes/Akismet.class.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Introducirmos la API key para nuestra web</span>
<span style="color: #000088;">$api_key</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'aqui va la clave'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$blog_url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://www.miweb.com&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Creamos el objeto Akismet</span>
<span style="color: #000088;">$akismet</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Akismet<span style="color: #009900;">&#40;</span><span style="color: #000088;">$blog_url</span> <span style="color: #339933;">,</span><span style="color: #000088;">$api_key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Condicional para ver si la clave es válida</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$akismet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isKeyValid</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Campos a filtrar</span>
<span style="color: #000088;">$akismet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setCommentAuthor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$nombre</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #000088;">$akismet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setCommentAuthorEmail</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$email</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$akismet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setCommentContent</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$comentarios</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$akismet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setCommentAuthorURL</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Enlace permanente donde el formulario es enviado</span>
<span style="color: #000088;">$akismet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setPermalink</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://www.ejemplo.com/una-url/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Decidimos qué hacer si es Spam y si no lo es</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$akismet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isCommentSpam</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
 <span style="color: #666666; font-style: italic;">// Aquí va el código, mensaje de error o lo que queramos, o incluso archivarlos en algún sitio para comprobarlos más adelante.</span>
 <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">// Aquí va el código en el caso de que NO sea Spam, que normalmente será continuar con cualquier proceso de validación o incluso ya con el envío del formulario.</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// Fin del condicional si la clave es válida</span></pre></td></tr></table></div>

<h3>Documentación adicional</h3>
<p><a href="http://akismet.com/" title="Ir a la web de Akismet">Web de Akismet</a><br />
<a href="http://akismet.com/development/api/" title="Documentación de Akismet">Documentación de Akismet</a><br />
Aching Brain, <a href="http://www.achingbrain.net/stuff/php/akismet" title="Ir a Aching Brain">Akismet para PHP5</a></p>
<div id="crp_related"><h3>Artículos relacionados:</h3><ul><li><a href="http://www.emenia.es/primeros-pasos-tras-una-nueva-instalacion-de-wordpress/" rel="bookmark" class="crp_title">Primeros pasos tras una nueva instalación de Wordpress</a></li><li><a href="http://www.emenia.es/utilizando-css3-hoy-1-bordes-redondeados/" rel="bookmark" class="crp_title">Utilizando CSS3 hoy (1): Bordes Redondeados</a></li><li><a href="http://www.emenia.es/curso-de-jquery-3-selectores-segunda-parte/" rel="bookmark" class="crp_title">Curso de jQuery (3): Selectores, Segunda Parte</a></li><li><a href="http://www.emenia.es/como-incrementar-la-seguridad-de-una-web-creada-con-wordpress/" rel="bookmark" class="crp_title">Cómo incrementar la seguridad de una web creada con Wordpress</a></li><li><a href="http://www.emenia.es/calendario-formulario-jquery/" rel="bookmark" class="crp_title">Elegir una fecha en un formulario con un calendario y jQuery</a></li></ul></div><img src="http://feeds.feedburner.com/~r/Emeniaes/~4/fDcNlvZ_skE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.emenia.es/formulario-filtrar-spam-akismet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.emenia.es/formulario-filtrar-spam-akismet/</feedburner:origLink></item>
		<item>
		<title>Os presento CodigoyTrucos.com</title>
		<link>http://feedproxy.google.com/~r/Emeniaes/~3/c1P2_5Ghkgw/</link>
		<comments>http://www.emenia.es/os-presento-codigoytrucos-com/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 11:25:41 +0000</pubDate>
		<dc:creator>Juan Diaz-Bustamante</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.emenia.es/?p=828</guid>
		<description><![CDATA[Sigo de manera diaria una gran cantidad de blogs sobre desarrollo, tanto en Castellano como en Inglés. Eso me lleva a tener la barra de favoritos una gran cantidad de páginas marcadas. Un día pensé que estaría bien llevar todos estos artículos que me gustan y que archivo para estudiarlos o para usos futuros a una web que los recogiera de manera constante y organizada. De ahí surgió la idea de http://www.codigoytrucos.com, recoger los mejores artículos de internet sobre desarrollo y diseño web.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.emenia.es%2Fos-presento-codigoytrucos-com%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.emenia.es%2Fos-presento-codigoytrucos-com%2F&amp;source=JuanDBB_Emenia&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Sigo de manera diaria una gran cantidad de blogs sobre desarrollo, tanto en Castellano como en Inglés. Eso me lleva a tener la barra de favoritos una gran cantidad de páginas marcadas. Un día pensé que estaría bien llevar todos estos artículos que me gustan y que archivo para estudiarlos o para usos futuros a una web que los recogiera de manera constante y organizada. De ahí surgió la idea de <a href="http://www.codigoytrucos.com">http://www.codigoytrucos.com</a>, recoger los mejores artículos de internet sobre desarrollo y diseño web.</p>
<p>Espero que os sea de utilidad. La web acaba de arrancar, por lo que aún le quedan algunos arreglos y mejoras, pero ya tiene contenido de dos días.</p>
<p>También busco con la web colaboración, para que enviéis aquellos enlaces que os parezcan de utilidad para los demás.</p>
<div id="crp_related"> </div><img src="http://feeds.feedburner.com/~r/Emeniaes/~4/c1P2_5Ghkgw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.emenia.es/os-presento-codigoytrucos-com/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.emenia.es/os-presento-codigoytrucos-com/</feedburner:origLink></item>
		<item>
		<title>Funciones útiles para functions.php en Wordpress</title>
		<link>http://feedproxy.google.com/~r/Emeniaes/~3/YHauSC5ANDc/</link>
		<comments>http://www.emenia.es/funciones-utiles-para-functions-php-en-wordpress/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 07:11:27 +0000</pubDate>
		<dc:creator>Juan Diaz-Bustamante</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.emenia.es/?p=764</guid>
		<description><![CDATA[El blog <a href="http://ayudawordpress.com" title="Ir a ayudawordpress.com"> ayudawordpress.com</a>, centrado en artículos sobre Wordpress, ha publicado hoy un artículo mío que quizás os pueda interesar. Se llama <a href=" 35 Funciones útiles para functions.php en Wordpress" title="Ir al artículo">35 Funciones útiles para functions.php en Wordpress</a> y recoje 35 funciones útiles (algunas más que otras) para incluir en el archivo functions.php de nuestro tema de Wordpress. Son especialmente útiles si creamos nuestro tema desde cero y le damos una funcionalidad propia.

Es el primer artículo que escribo en ayudawordpres.com, ha sido una buena experiencia que espero repetir cuando tenga algún otro artículo sobre Wordpress.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.emenia.es%2Ffunciones-utiles-para-functions-php-en-wordpress%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.emenia.es%2Ffunciones-utiles-para-functions-php-en-wordpress%2F&amp;source=JuanDBB_Emenia&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>El blog <a href="http://ayudawordpress.com" title="Ir a ayudawordpress">ayudawordpress.com</a>, centrado en artículos sobre Wordpress, ha publicado hoy un artículo mío que quizás os pueda interesar. Se llama <a href="http://ayudawordpress.com/35-funciones-utiles-para-functions-php-en-wordpress/#more-7607" title="Ir al artículo">35 Funciones útiles para functions.php en Wordpress</a> y recoje 35 funciones útiles (algunas más que otras) para incluir en el archivo functions.php de nuestro tema de Wordpress. Son especialmente útiles si creamos nuestro tema desde cero y le damos una funcionalidad propia.</p>
<p>Es el primer artículo que escribo en ayudawordpres.com, ha sido una buena experiencia que espero repetir cuando tenga algún otro artículo sobre Wordpress.</p>
<div id="crp_related"><h3>Artículos relacionados:</h3><ul><li><a href="http://www.emenia.es/la-funcion-body_class-en-wordpress/" rel="bookmark" class="crp_title">Clases dinámicas en body utilizando la función body_class() de Wordpress</a></li><li><a href="http://www.emenia.es/como-limitar-el-numero-de-palabras-en-the_content-o-the_excerpt-en-wordpress/" rel="bookmark" class="crp_title">Cómo limitar el número de palabras en the_content o the_excerpt en Wordpress</a></li><li><a href="http://www.emenia.es/como-utilizar-un-fondo-aleatorio-para-nuestra-web/" rel="bookmark" class="crp_title">Como utilizar un fondo aleatorio para nuestra web</a></li><li><a href="http://www.emenia.es/nuevo-en-wordpress-2-9-miniaturas-de-entrada-post-thumbnails/" rel="bookmark" class="crp_title">Nuevo en Wordpress 2.9: Miniaturas de Entrada (Post Thumbnails)</a></li><li><a href="http://www.emenia.es/barra-lateral-diferente-para-cada-pagina-en-wordpress/" rel="bookmark" class="crp_title">Barra Lateral diferente para cada página en Wordpress</a></li></ul></div><img src="http://feeds.feedburner.com/~r/Emeniaes/~4/YHauSC5ANDc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.emenia.es/funciones-utiles-para-functions-php-en-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.emenia.es/funciones-utiles-para-functions-php-en-wordpress/</feedburner:origLink></item>
		<item>
		<title>Crea tu propia red social con Wordpress y BuddyPress – Introducción</title>
		<link>http://feedproxy.google.com/~r/Emeniaes/~3/Osg-K-zzgNM/</link>
		<comments>http://www.emenia.es/crea-tu-propia-red-social-con-wordpress-y-buddypress-introduccion/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 09:22:07 +0000</pubDate>
		<dc:creator>Juan Diaz-Bustamante</dc:creator>
				<category><![CDATA[BuddyPress]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.emenia.es/?p=728</guid>
		<description><![CDATA[Vamos a ver cómo crear nuestra propia red social gracias a <strong>Wordpress</strong> y a <strong>BuddyPress</strong>. BudyPress es un impresionante plugin de Wordpress que transforma nuestra instalación de Wordpress en una potente red social. ]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.emenia.es%2Fcrea-tu-propia-red-social-con-wordpress-y-buddypress-introduccion%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.emenia.es%2Fcrea-tu-propia-red-social-con-wordpress-y-buddypress-introduccion%2F&amp;source=JuanDBB_Emenia&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Vamos a ver cómo crear nuestra propia red social gracias a <strong>Wordpress</strong> y a <strong>BuddyPress</strong>. BudyPress es un impresionante plugin de Wordpress que transforma nuestra instalación de Wordpress en una potente red social. Antiguamente BuddyPress sólo funcionaba sobre Wordpress MU (Wordpress multiusuario), pero ahora<strong> desde BudyPress 1.2 <a href="http://wordpress.org/development/2010/02/buddypress-for-one-and-all-3/" title="Ir a la noticia">podemos ya instalarlo</a> sobre una versión normal de Wordpress</strong> (eso sí, hasta que no salga Wordpress 3.0 no podremos aprovechar la posibilidad de que los usuarios tengan sus propios blogs). Para empezar tenemos que:</p>
<p><img src="http://www.emenia.es/wp-content/uploads/2010/03/web.jpg" alt="" title="web" width="550" height="444" class="alignleft size-full wp-image-742" /><br />
<br class="clear" /><br />
1) Instalar Wordpress<br />
2) Instalar BuddyPress desde Plugins/Añadir, buscando BuddyPress. Alternativamente podemos bajarnos la última versión de <a href="http://buddypress.org/" title="Ir a Buddypress">BuddyPress</a>, decomprimirla y subirla a la carpeta de plugins.<br />
3) Tenemos que cercionarnos que tenemos activados los enlaces permanentes en nuestra instalación de Wordpress.<br />
4) Ahora en el gestor de Wordpress veremos que podemos activar BuddyPress desde la sección de plugins.<br />
5) Seleccionar un tema compatible con Buddypress. Desde el administrador de Wordpress entramos en Apariencia y seleccionamos el tema por defecto de Buddypress (Default).<br />
6) Traducir Buddypress al Castellano (doy por supuesto que tenemos ya Wordpress en Castellano). Para ello, buscamos dentro de la carpeta de wp-content/plugins la carpeta de buddypress. Dentro de esta hay una carpeta llamada bp-languages. Aquí copiamos el archivo buddypress-es_ES.mo que obtenemos de <a href="http://www.buddypress-es.com/noticias/descargas/" title="Ir a buddypress-es.com">buddypress-es.com</a>.</p>
<p>Ahora ya deberíamos tener Buddypress funcionando. Como podemos ver, tenemos una red social ya de inicio bastante potente. A partir de aquí nos toca trabajar para dar a nuestra red social una apariencia y funcionamiento que se ajuste a nuestras preferencias.</p>
<p>Para <strong>configurar las opciones de Buddypress </strong>podéis ver que en el administrador de Wordpress hay ahora un apartado entero de Buddypress:</p>
<p><a href="http://www.emenia.es/wp-content/uploads/2010/03/opciones.jpg"><img src="http://www.emenia.es/wp-content/uploads/2010/03/opciones.jpg" alt="" title="opciones" width="156" height="372" class="alignleft size-full wp-image-756" /></a><br />
<br class="clear" /></p>
<p>Si además queremos crear un nuevo tema lo mejor, y hasta que tengamos un control grande sobre Buddypress y podamos crear un tema desde cero, es trabajar y modificar el tema que viene por defecto. Para ello los desarrolladores de Buddypress nos recomiendan que <a href="http://codex.buddypress.org/how-to-guides/building-a-buddypress-child-theme/" title="Ir al artículo">extendamos ese tema por defecto</a> (llamado default). Esto nos permitirá heredar los estilos, los scripts, AJAX etc.. del original que queramos conservar y sobreescribir lo que queramos cambiar. </p>
<p><strong>¿Cómo lo extendemos?</strong> Primero de todo creamos una carpeta en wp-content/themes con el nombre de nuestro tema, como si se tratara de un tema normal de Wordpress. En esta carpeta incluiremos sólo aquellas partes de nuestro tema (estilos, templates, etc..) <strong>que vayan a sobreescribir lo existente en el tema por defecto de BuddyPress</strong> (que se encuentra en wp-content/plugins/buddypress/bp-themes/bp-default, es decir, no en donde habitualmente tenemos nuestros temas en Wordpress).</p>
<p>Un buen método para sobreescribir cualquier template es copiarlo desde la carpeta del tema default de Buddypress a la carpeta de nuestro tema, y desde ahí cambiarlo (sin tocar el original. Es peligroso funcionar desde el original directamente ya que en cualquier actualización este se sobreescribirá entero). También podrás añadir en la nueva carpeta de tu tema cualquier archivo nuevo y propio de CSS, php, javascript, etc.. <strong>Cualquier archivo sobreescribirá al original del mismo nombre</strong>.</p>
<p><strong>El primer paso es crear la hoja de estilos nueva</strong>. La crearemos dentro de la nueva carpeta de nuestro tema (supongamos que nuestro tema se llama Test, y estará en /wp-content/themes/test). En esta carpeta crearemos un archivo de estilos al que llamaremos “style.css”. Esta será la hoja de estilos de nuestro nuevo tema para dar una apariencia personalizada a nuestra nueva red social.</p>
<p>Abre “style.css” y escribe:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*
Theme Name: BuddyPress Test
Theme URI: http://dondesea/
Description: Nuevo tema para BuddyPress.
Version: 1.0
Author: Nuestro Nombre
Author URI: http://nuestaweb/
Template: bp-default
Tags: buddypress
*/</span>
<span style="color: #808080; font-style: italic;">/* Para heredar los archivos de estilo. Si quieres crear todo de cero no la incluyas */</span>
<span style="color: #a1a100;">@import url( ../../plugins/buddypress/bp-themes/bp-default/_inc/css/default.css );</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* Para heredar los estilos de la barra de administración. Si quieres crear todo de cero no la incluyas */</span>
<span style="color: #a1a100;">@import url( ../../plugins/buddypress/bp-themes/bp-default/_inc/css/adminbar.css );</span></pre></td></tr></table></div>

<p>En <strong>&#8220;Template:&#8221;</strong> vemos como le decimos a Wordpress que queremos utilizar el tema por defecto de Wordpress (bp-default) como &#8220;tema padre&#8221; y heredar todos los templates y estilos de este. En <strong>&#8220;Tags:&#8221; </strong>pone buddypress, lo cual indica a Wordpress que estamos usando un tema de buddypress.</p>
<p>Graba el archivo y activa el nuevo tema (que hemos llamado Test) desde el administrador de Wordpress (en Apariencia). </p>
<p>A partir de aquí, en tu hoja de estilos nueva puedes sobreescribir cualquier estilo del original. Como comentaba antes cualquier archivo que grabes en la carpeta del nuevo tema que tenga igual nombre que el del original (por ejemplo, header.php) se cargará en lugar del original. <strong>Sólo hay una excepción a esta regla:</strong> aunque crees un archivo functions.php nuevo el original también se cargará.</p>
<p>Bueno, pues ha llegado el momento de enredar con nuestra nueva red social, con sus configuraciones, estilos, templates, etc&#8230;  En siguientes artículos entraré un poco más en detalle en el funcionamiento interno de BuddyPress.</p>
<h3>Webs recomendadas</h3>
<p><a href="http://buddypress.org/" title="Ir a la web de BuddyPress">Web oficial de BuddyPress</a><br />
<a href="http://codex.buddypress.org/" title="Ir a la documentación de BuddyPress">Documentación de BuddyPress en la web oficial</a><br />
<a href="http://buddypress.org/extend/plugins/" title="Plugins de BuddyPress">Plugins de BuddyPress en la web oficial</a><br />
<a href="http://www.buddypress-es.com/" title="Ir a BuddyPress-es.com">Buddypress-es.com</a>, Buddypress en Castellano<br />
<a href="http://wpmu.org/" title="Ir a wpmu.org">wpmu.org</a><br />
<a href="http://premium.wpmudev.org/" title="Ir a wpmudev.org">wpmudev.org</a></p>
<div id="crp_related"><h3>Artículos relacionados:</h3><ul><li><a href="http://www.emenia.es/funciones-utiles-para-functions-php-en-wordpress/" rel="bookmark" class="crp_title">Funciones útiles para functions.php en Wordpress</a></li><li><a href="http://www.emenia.es/primeros-pasos-tras-una-nueva-instalacion-de-wordpress/" rel="bookmark" class="crp_title">Primeros pasos tras una nueva instalación de Wordpress</a></li><li><a href="http://www.emenia.es/curso-de-jquery-2-selectores-primera-parte/" rel="bookmark" class="crp_title">Curso de jQuery (2): Selectores, Primera Parte</a></li><li><a href="http://www.emenia.es/curso-de-jquery-introduccion-1/" rel="bookmark" class="crp_title">Curso de jQuery (1): Introducción</a></li><li><a href="http://www.emenia.es/curso-de-jquery-4-selectores-tercera-parte/" rel="bookmark" class="crp_title">Curso de jQuery (4): Selectores, Tercera Parte</a></li></ul></div><img src="http://feeds.feedburner.com/~r/Emeniaes/~4/Osg-K-zzgNM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.emenia.es/crea-tu-propia-red-social-con-wordpress-y-buddypress-introduccion/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.emenia.es/crea-tu-propia-red-social-con-wordpress-y-buddypress-introduccion/</feedburner:origLink></item>
		<item>
		<title>Nuevo en Wordpress 2.9: Miniaturas de Entrada (Post Thumbnails)</title>
		<link>http://feedproxy.google.com/~r/Emeniaes/~3/eFXgYcL7P7E/</link>
		<comments>http://www.emenia.es/nuevo-en-wordpress-2-9-miniaturas-de-entrada-post-thumbnails/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 21:47:29 +0000</pubDate>
		<dc:creator>Juan Diaz-Bustamante</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.emenia.es/?p=707</guid>
		<description><![CDATA[Una de las principales novedades que nos ha ofrecido Wordpress 2.9 es la posibilidad de crear Miniaturas de Entrada (en inglés Post Thumbnails). ¿Qué son las Miniaturas de Entrada? Son las imágenes que veréis en muchos blogs asociadas a las distintas entradas de dicho blog en su página principal. Veremos cómo incluirlas en nuestros temas.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.emenia.es%2Fnuevo-en-wordpress-2-9-miniaturas-de-entrada-post-thumbnails%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.emenia.es%2Fnuevo-en-wordpress-2-9-miniaturas-de-entrada-post-thumbnails%2F&amp;source=JuanDBB_Emenia&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Una de las principales novedades que nos ha ofrecido Wordpress 2.9 es la posibilidad de crear Miniaturas de Entrada (en inglés Post Thumbnails). ¿Qué son las Miniaturas de Entrada? Son las imágenes que veréis en muchos blogs asociadas a las distintas entradas de dicho blog en su página principal. Veamos por ejemplo nettuts+:</p>
<p><a href="http://www.emenia.es/wp-content/uploads/2010/03/nettuts.jpg"><img src="http://www.emenia.es/wp-content/uploads/2010/03/nettuts.jpg" alt="" title="nettuts" width="550" height="513" class="alignleft size-full wp-image-708" /></a></p>
<p><br class="clear" /><br />
Vemos que cada entrada tiene asociada a su izquierda una imagen (marcada con un círculo rojo) que ayuda a describir mejor el artículo asociado, además de mejorar la imagen general del blog. Hasta ahora la manera más habitual de conseguir situar estas miniaturas era mediante <strong>Campos Personalizados</strong>. Ahora hay ya una funcionalidad completa e independiente para crear las Miniaturas de Entrada. Vamos a verla en detalle.</p>
<p><strong>Para poder usar las Miniaturas de entrada tenemos que activarlas</strong>. Esto lo hacemos desde el archivo functions.php de nuestro tema. Escribimos:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'add_theme_support'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> add_theme_support<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post-thumbnails'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Simplemente indica que si existe la función<em> <strong>&#8216;add_theme_support&#8217;</strong></em> se ejecute <strong><em>add_theme_support(&#8216;post-thumbnails&#8217;)</em></strong>. Lo habilitará tanto para páginas como para entradas. Si lo quieres sólo para uno de ellos:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">add_theme_support<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'post-thumbnails'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'post'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Sólo para entradas</span>
add_theme_support<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'post-thumbnails'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'page'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Sólo para páginas</span></pre></td></tr></table></div>

<p>Ahora al ir a escribir o a editar una entrada, tendremos en la columna de la derecha una nueva ventana, llamada, como no, Miniatura de Entrada:</p>
<p><a href="http://www.emenia.es/wp-content/uploads/2010/03/miniatura1.jpg"><img src="http://www.emenia.es/wp-content/uploads/2010/03/miniatura1.jpg" alt="" title="miniatura1" width="292" height="76" class="alignleft size-full wp-image-712" /></a><br />
<br class="clear" /><br />
Si hacemos click sobre <strong><em>Establecer miniatura</em></strong> aparecerá la pantalla habitual para añadir una imagen. La seleccionamos y veremos entonces:</p>
<p><a href="http://www.emenia.es/wp-content/uploads/2010/03/miniatura21.jpg"><img src="http://www.emenia.es/wp-content/uploads/2010/03/miniatura21.jpg" alt="" title="miniatura2" width="500" height="667" class="alignleft size-full wp-image-716" /></a><br />
<br class="clear" /><br />
En la parte de abajo, junto a Insertar en la entrada, vemos el enlace <strong><em>Usar como miniatura</em></strong>. Ese es el enlace sobre el que hay que hacer click. Entonces veremos que en el cuadro de Miniatura de entrada aparece la imagen que hemos seleccionado:<br />
<a href="http://www.emenia.es/wp-content/uploads/2010/03/miniatura3.jpg"><img src="http://www.emenia.es/wp-content/uploads/2010/03/miniatura3.jpg" alt="" title="miniatura3" width="291" height="214" class="alignleft size-full wp-image-717" /></a><br />
<br class="clear" /><br />
Ahora ya tendremos la imagen asociada a nuestro artículo. Pero nos queda un último paso: tenemos que incluir unas líneas dentro del loop para que se muestre la miniatura de entrada. Para ello tonamos el archivo que muestre las entradas en nuestro tema (por ejemplo index.php) y buscamos el loop, es decir, lo incluido entre</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
// Aquí va lo que se llama el loop, es decir un bucle que muestra 
// las entradas de nuestro blog
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Es ahí, dentro del loop, donde añadiremos un código que va a añadir la miniatura de cada entrada. Símplemente hay que escribir esta línea:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Un loop sencillo podría parecerse más o menos a esto:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;h1&gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;&lt;/h1&gt; // Titulo de la entrada
<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> // Miniatura de entrada
<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> // El contenido de la entrada
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Si, para estar seguros, queremos saber si la entrada o artículo en cuestión tiene una miniatura asociada, podemos hacer:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> has_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">// esta entrada tiene una miniatura, pondremos aquí</span>
<span style="color: #666666; font-style: italic;">// un código que muestre la miniatura:</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
} else {
// esta entrada no tiene miniatura, podemos poner aquí
// algo alternativo, por ejemplo mostrar la miniatura mediante campos
// personalizados, como se hacía anteriormente, o una imagen
// genérica.
}
?&gt;</pre></td></tr></table></div>

<p>Se puede seleccionar también el tamaño de la miniatura:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">// Tamaño pequeño:
<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'thumbnail'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
// Tamaño mediano:
<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'medium'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
// Tamaño grande:
<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'large'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
// Especificando el tamaño:
<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">225</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">225</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>También se pueden añadir atributos como title y alt, así como una clase que nos servirá para dar estilo con nuestra hoja CSS:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">// Aplicando una clase que llamaremos clase_miniatura en este caso:
<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'medium'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'class'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'clase_miniatura'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
// Definiendo los atributos title y alt:
<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'medium'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'class'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'clase_miniatura'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'alt'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'atributo_alt'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'atributo_title'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>En el caso de no asignar ninguna clase podemos dar estilo a la miniatura con <strong><em>.wp-post-image {}</em></strong></p>
<p>Volvamos de nuevo al archivo functions.php de nuestro tema. Vimos al principio de todo que las Miniaturas teníamos que activarlas en dicho archivo. Podemos además especificar el tamaño de las miniaturas:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Miniaturas redimensionadas a 50x50px </span>
set_post_thumbnail_size<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">// Miniaturas cortadas a 50x50px</span>
set_post_thumbnail_size<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">50</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>O asignar un tamaño concreto (también en functions.php):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">add_image_size<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'custom-thumbnail'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">300</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">300</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Que usaríamos así dentro del loop (por ejemplo en index.php):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'custom-thumbnail'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Si queremos que en functions.php esté todo este código que hemos visto incluído de manera segura (es decir, tras comprobar que existe esa funcionalidad en nuestra versión de Wordpress), escribiríamos:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'add_theme_support'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// a partir de WP 2.9</span>
add_theme_support<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post-thumbnails'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// activa las miniaturas</span>
set_post_thumbnail_size<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">50</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// especifica su tamaño</span>
add_image_size<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'custom-thumbnail'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">500</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">500</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// tamaño concreto</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Y para más seguridad, podemos poner como vimos antes, dentro del loop, el condicional que muestra las miniaturas. En el caso de que esta no exista podemos poner un plan alternativo, como puede ser una imagen de un campo personalizado:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'has_post_thumbnail'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>has_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$postimageURL</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post-image'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$postimageURL</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;img src=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$postimageURL</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; alt=&quot;&quot; /&gt;'</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h3>Lecturas recomendadas</h3>
<p>bocabit.com: <a href="http://bocabit.com/tecnologia/informatica/tutorial/todo-sobre-las-miniaturas-thumbnails-de-wordpress-2-9.php" title="Ir al artículo">Todo sobre las miniaturas (thumbnails) de Wordpress 2.9</a><br />
Mark Jaquith: <a href="http://markjaquith.wordpress.com/2009/12/23/new-in-wordpress-2-9-post-thumbnail-images/" title="Ir al artículo">New in WordPress 2.9: Post Thumbnail Images</a><br />
Justin Tadlock: <a href="http://justintadlock.com/archives/2009/11/16/everything-you-need-to-know-about-wordpress-2-9s-post-image-feature" title="Ir al artículo">Everything you need to know about WordPress 2.9’s post image feature</a></p>
<div id="crp_related"><h3>Artículos relacionados:</h3><ul><li><a href="http://www.emenia.es/taxonomias-en-wordpress/" rel="bookmark" class="crp_title">Taxonomías en Wordpress</a></li><li><a href="http://www.emenia.es/como-limitar-el-numero-de-palabras-en-the_content-o-the_excerpt-en-wordpress/" rel="bookmark" class="crp_title">Cómo limitar el número de palabras en the_content o the_excerpt en Wordpress</a></li><li><a href="http://www.emenia.es/lista-productos-wordpress-3/" rel="bookmark" class="crp_title">Crear una lista de productos con Wordpress 3.0 usando Entradas personalizadas, campos personalizados y taxonomías</a></li><li><a href="http://www.emenia.es/la-funcion-body_class-en-wordpress/" rel="bookmark" class="crp_title">Clases dinámicas en body utilizando la función body_class() de Wordpress</a></li><li><a href="http://www.emenia.es/recopilacion-de-45-trucos-para-wordpress/" rel="bookmark" class="crp_title">Recopilación de 45 trucos para Wordpress</a></li></ul></div><img src="http://feeds.feedburner.com/~r/Emeniaes/~4/eFXgYcL7P7E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.emenia.es/nuevo-en-wordpress-2-9-miniaturas-de-entrada-post-thumbnails/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.emenia.es/nuevo-en-wordpress-2-9-miniaturas-de-entrada-post-thumbnails/</feedburner:origLink></item>
		<item>
		<title>Taxonomías en Wordpress</title>
		<link>http://feedproxy.google.com/~r/Emeniaes/~3/m4Klxji6pJs/</link>
		<comments>http://www.emenia.es/taxonomias-en-wordpress/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 12:53:23 +0000</pubDate>
		<dc:creator>Juan Diaz-Bustamante</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.emenia.es/?p=568</guid>
		<description><![CDATA[Por defecto, Wordpress incluye tres taxonomías: categoría, etiquetas y categoría de los enlaces. En este artículo veremos cómo enriquecer las taxonomías de nuestro tema de Wordpress creando nuestras propias Taxonomías.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.emenia.es%2Ftaxonomias-en-wordpress%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.emenia.es%2Ftaxonomias-en-wordpress%2F&amp;source=JuanDBB_Emenia&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>El uso de <strong>Categorías</strong> y de <strong>Etiquetas</strong> (Tags en Inglés) es muy habitual en Wordpress. A la hora de crear una nueva entrada podemos asignarle una categoría (normalmente una categoría por entrada) y uno o varias etiquetas (normalmente varias etiquetas por entrada). Esto nos permite clasificar la información que estamos publicando para que luego sea más sencillo acceder a ella en función de las necesidades del usuario.</p>
<p>Tanto las Categorías como las Etiquetas son <strong>Taxonomías</strong>. ¿Qué es una Taxonomía? Veamos lo que dice el diccionario:</p>
<p><em><strong>taxonomía.</strong> Ciencia que trata de los principios, métodos y fines de la clasificación. Se aplica en particular, dentro de la biología, para la ordenación jerarquizada y sistemática, con sus nombres, de los grupos de animales y de vegetales. <strong>2.</strong> Por ext., clasificación.</em></p>
<p>Por defecto, Wordpress incluye tres taxonomías: categoría, etiquetas y categoría de los enlaces. En este artículo veremos cómo enriquecer las taxonomías de nuestro tema de Wordpress creando nuestras propias Taxonomías.</p>
<p>Desde Wordpress 2.8 es mucho más sencillo <strong>crear Taxonomías propias (Custom Taxonomies en Inglés)</strong> que nos pueden dar más flexibilidad que las tradicionales Categorías y Etiquetas. Esto puede sernos de utilizad para entradas que requieren un número alto de criterios de clasificación, de tal forma que las Categorías y las Etiquetas se nos queden cortas. </p>
<p>Por ejemplo, imaginémonos que tenemos una web de música y queremos introducir canciones y clasificarlas por Artista, Album, Género, Epoca, Autor, Duración, etc&#8230; Necesitamos la ayuda de las Taxonomías creadas por el usuario. Veremos que funcionan de manera muy parecida a las etiquetas.</p>
<p>Sigamos con el ejemplo de la web de música. Supongamos que tenemos esta canción:<br />
Shine on your Crazy Diamond<br />
Artista: Pink Floyd<br />
Album: Wish you were here<br />
Género: Rock Progresivo<br />
Autor: Pink Floyd<br />
Duración: 13:32 minutos<br />
Fecha: 1975</p>
<p>La idea es poder fijar toda esta información a una entrada que realices sobre esta canción de forma parecida a como lo harías con las etiquetas. Para empezar tienes que <strong>registrar las taxonomías</strong> para luego poder utilizarlas. Esto lo haces en el archivo <strong>functions.php </strong>de tu tema de Wordpress. Escribríamos:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">function</span> taxonomias_propias<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        register_taxonomy<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'artista'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                    <span style="color: #0000ff;">'hierarchical'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Artista'</span><span style="color: #339933;">,</span>
                    <span style="color: #0000ff;">'query_var'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'rewrite'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        register_taxonomy<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'album'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                    <span style="color: #0000ff;">'hierarchical'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Album'</span><span style="color: #339933;">,</span>
                    <span style="color: #0000ff;">'query_var'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'rewrite'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        register_taxonomy<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'genero'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                    <span style="color: #0000ff;">'hierarchical'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Género'</span><span style="color: #339933;">,</span>
                    <span style="color: #0000ff;">'query_var'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'rewrite'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        register_taxonomy<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'autor'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                    <span style="color: #0000ff;">'hierarchical'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Autor'</span><span style="color: #339933;">,</span>
                    <span style="color: #0000ff;">'query_var'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'rewrite'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        register_taxonomy<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'duracion'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                    <span style="color: #0000ff;">'hierarchical'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Duración'</span><span style="color: #339933;">,</span>
                    <span style="color: #0000ff;">'query_var'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'rewrite'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        register_taxonomy<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'fecha'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                    <span style="color: #0000ff;">'hierarchical'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Fecha'</span><span style="color: #339933;">,</span>
                    <span style="color: #0000ff;">'query_var'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'rewrite'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'taxonomias_propias'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Vamos a ver en detalle qué hemos hecho. Tomemos la primera taxonomía, <strong><em>artista</em></strong>:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">register_taxonomy<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'artista'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
         <span style="color: #0000ff;">'hierarchical'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Artista'</span><span style="color: #339933;">,</span>
         <span style="color: #0000ff;">'query_var'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'rewrite'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><strong><em>artista</em></strong> le dice a Wordpress cuál es el nombre de la Taxonomía. </p>
<p><strong><em>post</em></strong> indica el tipo de objeto sobre el que se aplica la Taxonomía, en este caso entradas (post). <strong>Más abajo veremos cómo crear taxonomías en páginas. </strong></p>
<p><strong><em>hierarchical</em></strong> indica si los términos de la taxonomía van a estar jerarquizados (las categorías lo estan, las etiquetas no). Lo ponemos como false (falso) para que se comporten como las etiquetas.</p>
<p><strong><em>Artista</em></strong> es el nombre de la taxonomía tal y como queremos que aparezca en el panel de administración de Wordpress. </p>
<p><strong><em>query_var</em></strong> permite saber a WordPress si vas a querer poder seleccionar artículos utilizando la taxonomía. Más adelante veremos cómo. Ponemos TRUE (es decir, que sí vamos a querer poder hacerlo).</p>
<p><strong><em>rewrite</em></strong> es para si quieres que Wordpress ofrezca urls amigables cuando se vea una página o archivo de una taxonomía (por ejemplo www.tusitio.es/autor/pink-floyd). Como sí queremos, ponemos TRUE (cierto).</p>
<p>Bien, ya hemos registrado nuestras taxonomías propias en el archivo functions.php de nuestro tema. Ahora si entramos en el administrador de Wordpress y abrimos o creamos una nueva entrada veremos que la columna lateral derecha (donde están las categorías y las etiquetas) ha cambiado. Ahora veremos (tengo una instalación de Wordpress en inglés, pero si lo tenéis en Castellano os saldrá bien):</p>
<p><a href="http://www.emenia.es/wp-content/uploads/2010/03/taxonomies-1.jpg"><img src="http://www.emenia.es/wp-content/uploads/2010/03/taxonomies-1.jpg" alt="" title="Taxonomías Propias" width="300" height="792" class="alignleft size-full wp-image-670" /></a><br />
<br class="clear" /></p>
<p>Veremos que en cada casilla de cada nueva taxonomía podemos añadir una nueva etiqueta. Si, el funcionamiento ahora es como el de las etiquetas normales, lo que pasa es que ahora tenemos varios grupos personalizados de etiquetas.</p>
<p>También saldrás las taxonomías nuevas en el menú de la izquierda, al desplegar Entradas.</p>
<p>Una vez publicada la entrada podemos acceder directamente, por ejemplo, a </p>
<p>http://www.tusitio.es/autor/pink-floyd/</p>
<p>Estas nuevas URLs utilizarán archive.php de tu tema de Wordpress para mostrar todas las entradas que correspondan a esa taxonomía. </p>
<p>Si queremos <strong>mostrar una nube de etiquetas</strong> de una taxonomía en concreto (por ejemplo todos los Autores) lo haríamos con este código en cualquier sítio de cualquier archivo de nuestro tema:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;h3&gt;Autores&lt;/h3&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_tag_cloud<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'taxonomy'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'autor'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'number'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>En vez de autor pondríamos el nombre de la taxonomía que queramos, y en número (number) el número de etiquetas a mostrar de esa taxonomía (si ponemos 0, como en este caso, salen todas).</p>
<p>Si queremos que salgan<strong> todas las taxonomías y su nube de etiquetas</strong> podemos seguir las indicaciones de <a href="http://justintadlock.com/archives/2009/05/02/creating-a-page-template-that-lists-all-of-your-wordpress-taxonomies" title="Ir al artículo">justintadlock.com</a>:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_taxonomies</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$wp_taxonomies</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$wp_taxonomies</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$tax</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
		&lt;h2 class=&quot;taxonomy-label&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$tax</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">label</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/h2&gt;
&nbsp;
		&lt;p class=&quot;taxonomy-cloud&quot;&gt;
			<span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_tag_cloud<span style="color: #009900;">&#40;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'taxonomy'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$tax</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'number'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
		&lt;/p&gt;&lt;!-- .taxonomy-cloud --&gt;
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Para <strong>mostrar todas las entradas que tengan una etiqueta concreta</strong> de una de nuestras taxonomías (por ejemplo, las 15 primeras entradas entradas con autor Pink Floyd) tendríamos que situar este código antes del loop de uno de los archivos de nuestro tema:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> query_posts<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'autor'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Pink Floyd'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'showposts'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
// Y ahora va el loop:
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
// Etc..</pre></td></tr></table></div>

<p>Si queremos que se <strong>muestre para cada artículo una taxonomía concreta y los enlaces de las etiquetas relacionadas</strong> (por ejemplo, Autor: <u>Pink Floyd</u> donde Pink Floyd es un enlace)  utilizaríamos este código en el sitio donde queremos que salgan los enlaces de las etiquetas separadas con comas dentro del loop:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> get_the_term_list<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'autor'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Autor: '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">', '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Los tres últimos parámetros le indican a Wordpress qué escribir antes de los enlaces de las etiquetas, entre cada enlace y tras cada enlace.</p>
<p><strong>Condicionales que podemos usar con las taxonomías:</strong><br />
 is_tax(), is_tax(&#8216;nombre-de-la-taxonomia&#8217;), is_tax(array(&#8216;nombre1&#8242;,&#8217;nombre2&#8242;,&#8217;nombre3&#8242;)) </p>
<p>Como veis el uso de las taxonomías es muy sencillo y nos puede permitir mejorar el uso de Wordpress para crear webs de mayor complejidad. Gracias a la posibilidad de crear nuevas plantillas y sabiendo que podemos acceder a una taxonomía en concreto a través de una url amigable podemos crear menús y submenús con facilidad en los que accedamos a páginas concretas para cada taxonomía, por ejemplo. </p>
<h3>Taxonomías en páginas</h3>
<p>En el ejemplo anterior creábamos taxonomías para su uso en entradas (posts). Ahora veremos cómo crearlas en las <em>páginas</em>.<br />
Fuente: <a href="http://justintadlock.com/archives/2009/11/09/excerpts-and-taxonomies-for-pages-in-wordpress-2-9" title="Ir al artículo">http://justintadlock.com/archives/2009/11/09/excerpts-and-taxonomies-for-pages-in-wordpress-2-9</a><br />
Hay que recordar que en Wordpress 2.9 las Taxonomías no admiten jerarquización, como las categorías.<br />
Supongamos que creamos una Taxonomía para páginas llamada &#8220;people&#8221;:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">register_taxonomy<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'people'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'page'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'hierarchical'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'People'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'query_var'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'rewrite'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'admin_menu'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'my_page_taxonomy_meta_boxes'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> my_page_taxonomy_meta_boxes<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> get_object_taxonomies<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'page'</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$tax_name</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>is_taxonomy_hierarchical<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$tax_name</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$tax</span> <span style="color: #339933;">=</span> get_taxonomy<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$tax_name</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			add_meta_box<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;tagsdiv-<span style="color: #006699; font-weight: bold;">{$tax_name}</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$tax</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">label</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post_tags_meta_box'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'page'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'side'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'core'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<div id="crp_related"><h3>Artículos relacionados:</h3><ul><li><a href="http://www.emenia.es/funciones-utiles-para-functions-php-en-wordpress/" rel="bookmark" class="crp_title">Funciones útiles para functions.php en Wordpress</a></li><li><a href="http://www.emenia.es/lista-productos-wordpress-3/" rel="bookmark" class="crp_title">Crear una lista de productos con Wordpress 3.0 usando Entradas personalizadas, campos personalizados y taxonomías</a></li><li><a href="http://www.emenia.es/la-funcion-body_class-en-wordpress/" rel="bookmark" class="crp_title">Clases dinámicas en body utilizando la función body_class() de Wordpress</a></li><li><a href="http://www.emenia.es/automatiza-el-ano-del-copyright-en-tu-web/" rel="bookmark" class="crp_title">Automatiza el año del copyright en tu web</a></li><li><a href="http://www.emenia.es/crea-tu-propia-red-social-con-wordpress-y-buddypress-introduccion/" rel="bookmark" class="crp_title">Crea tu propia red social con Wordpress y BuddyPress &#8211; Introducción</a></li></ul></div><img src="http://feeds.feedburner.com/~r/Emeniaes/~4/m4Klxji6pJs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.emenia.es/taxonomias-en-wordpress/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://www.emenia.es/taxonomias-en-wordpress/</feedburner:origLink></item>
		<item>
		<title>Elegir una fecha en un formulario con un calendario y jQuery</title>
		<link>http://feedproxy.google.com/~r/Emeniaes/~3/7QeJAYl3MKI/</link>
		<comments>http://www.emenia.es/calendario-formulario-jquery/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 21:56:56 +0000</pubDate>
		<dc:creator>Juan Diaz-Bustamante</dc:creator>
				<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://www.emenia.es/?p=615</guid>
		<description><![CDATA[Vamos a ver cómo crear un calendario que se abra de manera automática para introducir una fecha en un formulario. Lo haremos con jQuery y su plugin Query UI Datepicker]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.emenia.es%2Fcalendario-formulario-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.emenia.es%2Fcalendario-formulario-jquery%2F&amp;source=JuanDBB_Emenia&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>En ocasiones necesitamos crear un formulario donde alguno de los campos requieren la selección de una fecha por parte del usuario, por ejemplo para la reserva de la habitación de un hotel, la compra de un billete de tren, etc..</p>
<p>La mejor manera de solicitar una fecha al usuario es a través de un calendario que se despliegue a la hora de introducir la fecha. Es lo que vamos a hacer en este ejemplo.</p>
<p>Para ello vamos a utilizar el plugin <a href="http://docs.jquery.com/UI/Datepicker" title="Ir a la web de UI Datapicker">jQuery UI Datepicker</a>. </p>
<p>Lo que vamos a conseguir es esto:</p>
<p><a href="http://www.emenia.es/wp-content/uploads/2010/02/imagen_blog.jpg"><img src="http://www.emenia.es/wp-content/uploads/2010/02/imagen_blog.jpg" alt="" title="imagen_blog" width="417" height="230" class="aligncenter size-full wp-image-620" /></a></p>
<p>Para utilizarlo necesitamos:</p>
<p>1) <strong>jQuery</strong>, por supuesto:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>2) <strong>jQuery UI</strong>:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>3) En cuanto a estilos, utilizaremos el <a href="http://jqueryui.com/themeroller/?ctl=themeroller">jQuery UI CSS Framework</a> (esta línea debería ir antes de las dos anteriores en nuestro código):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/jquery-ui-1.7.2.custom.css&quot; /&gt;</pre></td></tr></table></div>

<p>Y sus iconos:<br />
<a href="http://www.emenia.es/wp-content/uploads/2010/02/ui-icons_222222_256x240.png"><img src="http://www.emenia.es/wp-content/uploads/2010/02/ui-icons_222222_256x240.png" alt="" title="ui-icons_222222_256x240" width="256" height="240" class="aligncenter size-full wp-image-617" /></a></p>
<p>Si seguimos las instrucciones del plugin, vemos que utilizar el calendario para seleccionar una fecha es realmente sencillo. Sólo hay que escribir, en su forma más básica:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#datepicker&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">datepicker</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Siendo en este caso &#8220;#datapicker&#8221; el id del input del formulario al que aplicamos el calendario:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;input type=&quot;text&quot; name=&quot;datepicker&quot; id=&quot;datepicker&quot; readonly=&quot;readonly&quot; size=&quot;12&quot; /&gt;</pre></td></tr></table></div>

<p>Como veréis le hemos añadido el atributo <em>readonly</em> para que no pueda ser modificado el contenido del input por el usuario, es decir, que se quede la fecha elegida sin poder alterarla manualmente. Aunque algunos autores lo incluyen, es probable que sea mejor no incluirlo, ya que si Javascript está desactivado no podríamos escribir nada en el input.</p>
<p>Si unís todo el código anterior veréis que el calendario sale en inglés. Para ponerlo en Castellano (también se puede poner en Catalán o en Euskera) tenemos los <a href="http://jquery-ui.googlecode.com/svn/trunk/ui/i18n/" title="Ver los archivos de localización">archivos de localización</a>.</p>
<p>En concreto, para que esté en Castellano:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">jQuery<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$.<span style="color: #660066;">datepicker</span>.<span style="color: #660066;">regional</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'es'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
		closeText<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Cerrar'</span><span style="color: #339933;">,</span>
		prevText<span style="color: #339933;">:</span> <span style="color: #3366CC;">'&amp;#x3c;Ant'</span><span style="color: #339933;">,</span>
		nextText<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Sig&amp;#x3e;'</span><span style="color: #339933;">,</span>
		currentText<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Hoy'</span><span style="color: #339933;">,</span>
		monthNames<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'Enero'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Febrero'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Marzo'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Abril'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Mayo'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Junio'</span><span style="color: #339933;">,</span>
		<span style="color: #3366CC;">'Julio'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Agosto'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Septiembre'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Octubre'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Noviembre'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Diciembre'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
		monthNamesShort<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'Ene'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Feb'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Mar'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Abr'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'May'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Jun'</span><span style="color: #339933;">,</span>
		<span style="color: #3366CC;">'Jul'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Ago'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Sep'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Oct'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Nov'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Dic'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
		dayNames<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'Domingo'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Lunes'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Martes'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Mi&amp;eacute;rcoles'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Jueves'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Viernes'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'S&amp;aacute;bado'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
		dayNamesShort<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'Dom'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Lun'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Mar'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Mi&amp;eacute;'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Juv'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Vie'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'S&amp;aacute;b'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
		dayNamesMin<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'Do'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Lu'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Ma'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Mi'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Ju'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Vi'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'S&amp;aacute;'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
		weekHeader<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Sm'</span><span style="color: #339933;">,</span>
		dateFormat<span style="color: #339933;">:</span> <span style="color: #3366CC;">'dd/mm/yy'</span><span style="color: #339933;">,</span>
		firstDay<span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span>
		isRTL<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span>
		showMonthAfterYear<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span>
		yearSuffix<span style="color: #339933;">:</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
	$.<span style="color: #660066;">datepicker</span>.<span style="color: #660066;">setDefaults</span><span style="color: #009900;">&#40;</span>$.<span style="color: #660066;">datepicker</span>.<span style="color: #660066;">regional</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'es'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Vamos a unir ya todo el código antes de ver posibles modificaciones. Podéis ver este código funcionando en esta <a href="http://www.emenia.es/demos-blog/calendario/" title="Ir a demostración" rel="nofollow">demostración</a> y podéis bajar el código <a href="http://www.emenia.es/demos-blog/calendario/calendario.zip" rel="nofollow" title="Descargar código">aquí</a>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
   &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; lang=&quot;es&quot; xml:lang=&quot;es&quot;&gt;
&lt;head&gt;
&lt;title&gt;Emenia Demo - Uso de jQuery Data Picker&lt;/title&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/jquery-ui-1.7.2.custom.css&quot; /&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
jQuery(function($){
	$.datepicker.regional['es'] = {
		closeText: 'Cerrar',
		prevText: '&amp;#x3c;Ant',
		nextText: 'Sig&amp;#x3e;',
		currentText: 'Hoy',
		monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio',
		'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
		monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun',
		'Jul','Ago','Sep','Oct','Nov','Dic'],
		dayNames: ['Domingo','Lunes','Martes','Mi&amp;eacute;rcoles','Jueves','Viernes','S&amp;aacute;bado'],
		dayNamesShort: ['Dom','Lun','Mar','Mi&amp;eacute;','Juv','Vie','S&amp;aacute;b'],
		dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','S&amp;aacute;'],
		weekHeader: 'Sm',
		dateFormat: 'dd/mm/yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};
	$.datepicker.setDefaults($.datepicker.regional['es']);
});    
&nbsp;
$(document).ready(function() {
   $(&quot;#datepicker&quot;).datepicker();
 });
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Uso de jQuery Data Picker&lt;/h1&gt;
&lt;form action=&quot;&quot;&gt;
  &lt;label&gt; Seleccionar Fecha:&lt;/label&gt;
  &lt;input type=&quot;text&quot; name=&quot;datepicker&quot; id=&quot;datepicker&quot; readonly=&quot;readonly&quot; size=&quot;12&quot; /&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>Ahora vamos a ver algunas formas de personalizar el calendario. Muchas de las opciones las hemos utilizado ya en el código de localización. La lista completa está en <a href="http://docs.jquery.com/UI/Datepicker" title="Ir a la página del plugin">http://docs.jquery.com/UI/Datepicker</a></p>
<p>- <strong>altField y altFormat</strong> nos permiten guardar la fecha elegida en otro campo con un formato diferente, por ejemplo si lo queremos mostrar al usuario con un formato pero que nos llegue a nosotros con otro diferente.</p>
<p>- <strong>appendText</strong>, si queremos que se muestre un texto al lado del input, para una mejor comprensión para el usuario:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">    $<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
           $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#datepicker&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">datepicker</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> appendText<span style="color: #339933;">:</span> <span style="color: #3366CC;">' Haga click para introducir una fecha'</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><a href="http://www.emenia.es/demos-blog/calendario/index2.htm" title="Ir a demostración">Ver una demo con appendText</a> </p>
<p>-<strong>autoSize</strong>, si lo ponemos en true se ajustará el input para dar cabida a la fecha introducida.</p>
<p>- <strong>numberOfMonths</strong>, para elegir el número de meses que van a salir. Si ponemos numberOfMonths:2, por ejemplo, saldrán dos meses. Esto lo aconsejan algunos expertos en usabilidad ya que hay más opción donde elegir de un solo vistazo. <a href="http://www.emenia.es/demos-blog/calendario/index3.htm" title="Ir a demostración">Veamos un ejemplo de numberOfMonths</a> , donde se añade al anterior de appendText para ver cómo se unen dos opciones.</p>
<p>- Si queremos que el calendario se despliegue no al hacer click sobre el input sino sobre un botón adjunto (por ejemplo, una imagen de un calendario pequeño, como tienen muchas webs que habréis visto), utilizaremos las opciones <strong>buttonImage, buttonImageOnly y showOn</strong>:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#datepicker&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">datepicker</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> 
   showOn<span style="color: #339933;">:</span> <span style="color: #3366CC;">'button'</span><span style="color: #339933;">,</span> 
   buttonImageOnly<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> 
   buttonImage<span style="color: #339933;">:</span> <span style="color: #3366CC;">'images/datepicker.png'</span> 
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>donde datapicker.png es un icono de un calendario. Al hacer click sobre él, se despliega el calendario. <a href="http://www.emenia.es/demos-blog/calendario/index4.htm" title="Ir a demostración">Veamos un ejemplo</a>. </p>
<p>- <strong>dateformat</strong>, para cambiar el formato en el que se pega la fecha al input. En la demo está en dateformat: &#8216;dd/mm/yy&#8217;. Otra opción es por ejemplo &#8216;DD, MM, d, yy&#8217; . <a href="http://docs.jquery.com/UI/Datepicker/formatDate" title="Ver lista completa de formatos de fecha">Lista completa de formatos de fecha</a>.</p>
<p>- <strong>maxDate y minDate</strong>, para poner una fecha máxima y otra mínima (supongamos que queremos que sólo salgan los meses de Junio a Octubre):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#datepicker&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">datepicker</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
       minDate<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2010</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
       maxDate<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2010</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">9</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">30</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
       dateFormat<span style="color: #339933;">:</span> <span style="color: #3366CC;">'dd/mm/yy'</span><span style="color: #339933;">,</span>
       constrainInput<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><a href="http://www.emenia.es/demos-blog/calendario/index5.htm" title="Ir a demostración" rel="nofollow">Veamos un ejemplo de maxDate y minDate</a>.</p>
<p>- <strong>buttonText</strong>, Si queremos que se abra el calendario al hacer click sobre un botón al que le ponemos nosotros el texto:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#datepicker&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">datepicker</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> 
       showOn<span style="color: #339933;">:</span> <span style="color: #3366CC;">'button'</span><span style="color: #339933;">,</span> 
       buttonText<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Seleccionar&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><a href="http://www.emenia.es/demos-blog/calendario/index6.htm" rel="nofollow" title="Ir a demostración">Veamos una demo del uso de buttonText</a>.</p>
<p>- <strong>showAnim</strong>, si queremos cambiar el efecto con el que se muestra el calendario</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#datepicker&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">datepicker</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    showAnim<span style="color: #339933;">:</span> <span style="color: #3366CC;">'fadeIn'</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><a href="http://www.emenia.es/demos-blog/calendario/index7.htm" rel="nofollow" title="Ir a demostración">Veamos una demo del uso de showAnim</a>. Podemos usar como efecto &#8217;show&#8217; (por defecto), &#8217;slideDown&#8217;, &#8216;fadeIn&#8217;, o cualquiera de los <a href="http://docs.jquery.com/UI/Effects" title="Ver lista de efectos">efectos para mostrar/ocultar de jQuery UI</a>.</p>
<p>- <strong>changeMonth</strong> permite mostrar una lista desplegable de meses para poder ir con mayor rapidez al mes deseado:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#datepicker&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">datepicker</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    changeMonth<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span> 
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><a href="http://www.emenia.es/demos-blog/calendario/index8.htm" rel="nofollow" title="Ir a demostración">Veamos una demo del uso de changeMonth</a></p>
<p>Id probando todas las opciones de la página del plugin para ver las distintas opciones.</p>
<p>Por último, destacar una variación aportada por David Walsh en su artículo <a href="http://davidwalsh.name/jquery-datepicker-disable-days" title="Ir al artículo">jQuery UI DatePicker: Disable Specified Days</a>, para desactivar días concretos (por ejemplo, días que hayan sido ya reservados de un hotel y por lo tanto no puedan ser ya escogidos). También en su ejemplo se ve como desactivar los fines de semana y días de fiesta.</p>
<div id="crp_related"><h3>Artículos relacionados:</h3><ul><li><a href="http://www.emenia.es/formulario-filtrar-spam-akismet/" rel="bookmark" class="crp_title">Filtrar el spam de un formulario con Akismet</a></li><li><a href="http://www.emenia.es/curso-de-jquery-2-selectores-primera-parte/" rel="bookmark" class="crp_title">Curso de jQuery (2): Selectores, Primera Parte</a></li><li><a href="http://www.emenia.es/utilizando-css3-hoy-1-bordes-redondeados/" rel="bookmark" class="crp_title">Utilizando CSS3 hoy (1): Bordes Redondeados</a></li><li><a href="http://www.emenia.es/como-pre-cargar-imagenes-con-jquery/" rel="bookmark" class="crp_title">Cómo pre-cargar imágenes con jQuery</a></li><li><a href="http://www.emenia.es/automatiza-el-ano-del-copyright-en-tu-web/" rel="bookmark" class="crp_title">Automatiza el año del copyright en tu web</a></li></ul></div><img src="http://feeds.feedburner.com/~r/Emeniaes/~4/7QeJAYl3MKI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.emenia.es/calendario-formulario-jquery/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.emenia.es/calendario-formulario-jquery/</feedburner:origLink></item>
	</channel>
</rss>
